From 278fb0e1930ea8af4fb8b838dbc63767516e3d7b Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Sat, 26 Feb 2022 08:51:56 +0000 Subject: [PATCH] Make use of Set when checking for contained objects. --- .../scripts/handlers/bypasshandlers/Link.java | 88 ++++++------ .../handlers/itemhandlers/PetFood.java | 3 +- .../OpCheckResidenceSkillCondition.java | 7 +- .../OpNeedSummonOrPetSkillCondition.java | 28 ++-- .../OpTargetDoorSkillCondition.java | 7 +- .../OpTargetNpcSkillCondition.java | 9 +- .../scripts/instances/AbstractInstance.java | 19 ++- .../java/org/l2jmobius/Config.java | 32 ++--- .../gameserver/data/xml/ClanHallData.java | 3 +- .../gameserver/data/xml/FakePlayerData.java | 6 +- .../instancemanager/SellBuffsManager.java | 10 +- .../instancemanager/WalkingManager.java | 4 +- .../l2jmobius/gameserver/model/BlockList.java | 15 ++- .../l2jmobius/gameserver/model/PetData.java | 6 +- .../gameserver/model/SkillLearn.java | 27 ++-- .../gameserver/model/actor/instance/Pet.java | 3 +- .../gameserver/model/actor/instance/Trap.java | 6 +- .../model/actor/tasks/player/PetFeedTask.java | 5 +- .../ConditionPlayerInsideZoneId.java | 6 +- .../conditions/ConditionPlayerInstanceId.java | 6 +- .../model/conditions/ConditionPlayerRace.java | 9 +- .../ConditionPlayerRangeFromNpc.java | 11 +- .../ConditionPlayerRangeFromSummonedNpc.java | 11 +- .../ConditionTargetClassIdRestriction.java | 6 +- .../conditions/ConditionTargetNpcId.java | 6 +- .../model/holders/EventDropHolder.java | 8 +- .../gameserver/model/item/Henna.java | 8 +- .../item/appearance/AppearanceStone.java | 55 ++++---- .../item/enchant/AbstractEnchantItem.java | 45 ++++--- .../gameserver/model/quest/LongTimeEvent.java | 4 +- .../gameserver/model/residences/ClanHall.java | 32 +++-- .../gameserver/model/siege/Castle.java | 6 +- .../serverpackets/BlockListPacket.java | 12 +- .../serverpackets/ExAcquireSkillInfo.java | 3 +- .../appearance/ExChooseShapeShiftingItem.java | 2 +- .../gameserver/util/DocumentBase.java | 37 ++--- .../scripts/handlers/bypasshandlers/Link.java | 94 ++++++------- .../handlers/itemhandlers/PetFood.java | 3 +- .../OpCheckResidenceSkillCondition.java | 7 +- .../OpNeedSummonOrPetSkillCondition.java | 28 ++-- .../OpTargetDoorSkillCondition.java | 7 +- .../OpTargetNpcSkillCondition.java | 9 +- .../scripts/instances/AbstractInstance.java | 19 ++- .../java/org/l2jmobius/Config.java | 32 ++--- .../gameserver/data/xml/ClanHallData.java | 3 +- .../gameserver/data/xml/FakePlayerData.java | 6 +- .../instancemanager/SellBuffsManager.java | 10 +- .../instancemanager/WalkingManager.java | 4 +- .../l2jmobius/gameserver/model/BlockList.java | 15 ++- .../l2jmobius/gameserver/model/PetData.java | 6 +- .../gameserver/model/SkillLearn.java | 27 ++-- .../gameserver/model/actor/instance/Pet.java | 3 +- .../gameserver/model/actor/instance/Trap.java | 6 +- .../model/actor/tasks/player/PetFeedTask.java | 5 +- .../ConditionPlayerInsideZoneId.java | 6 +- .../conditions/ConditionPlayerInstanceId.java | 6 +- .../model/conditions/ConditionPlayerRace.java | 9 +- .../ConditionPlayerRangeFromNpc.java | 11 +- .../ConditionPlayerRangeFromSummonedNpc.java | 11 +- .../ConditionTargetClassIdRestriction.java | 6 +- .../conditions/ConditionTargetNpcId.java | 6 +- .../model/holders/EventDropHolder.java | 8 +- .../gameserver/model/item/Henna.java | 8 +- .../item/appearance/AppearanceStone.java | 55 ++++---- .../item/enchant/AbstractEnchantItem.java | 45 ++++--- .../gameserver/model/quest/LongTimeEvent.java | 4 +- .../gameserver/model/residences/ClanHall.java | 32 +++-- .../gameserver/model/siege/Castle.java | 6 +- .../serverpackets/BlockListPacket.java | 12 +- .../serverpackets/ExAcquireSkillInfo.java | 3 +- .../appearance/ExChooseShapeShiftingItem.java | 2 +- .../gameserver/util/DocumentBase.java | 37 ++--- .../scripts/handlers/bypasshandlers/Link.java | 94 ++++++------- .../handlers/itemhandlers/PetFood.java | 3 +- .../OpCheckResidenceSkillCondition.java | 7 +- .../OpNeedSummonOrPetSkillCondition.java | 28 ++-- .../OpTargetDoorSkillCondition.java | 7 +- .../OpTargetNpcSkillCondition.java | 9 +- .../scripts/instances/AbstractInstance.java | 19 ++- .../java/org/l2jmobius/Config.java | 32 ++--- .../gameserver/data/xml/ClanHallData.java | 3 +- .../gameserver/data/xml/FakePlayerData.java | 6 +- .../instancemanager/SellBuffsManager.java | 10 +- .../instancemanager/WalkingManager.java | 4 +- .../l2jmobius/gameserver/model/BlockList.java | 15 ++- .../l2jmobius/gameserver/model/PetData.java | 6 +- .../gameserver/model/SkillLearn.java | 27 ++-- .../gameserver/model/actor/instance/Pet.java | 3 +- .../gameserver/model/actor/instance/Trap.java | 6 +- .../model/actor/tasks/player/PetFeedTask.java | 5 +- .../ConditionPlayerInsideZoneId.java | 6 +- .../conditions/ConditionPlayerInstanceId.java | 6 +- .../model/conditions/ConditionPlayerRace.java | 9 +- .../ConditionPlayerRangeFromNpc.java | 11 +- .../ConditionPlayerRangeFromSummonedNpc.java | 11 +- .../ConditionTargetClassIdRestriction.java | 6 +- .../conditions/ConditionTargetNpcId.java | 6 +- .../model/holders/EventDropHolder.java | 8 +- .../gameserver/model/item/Henna.java | 8 +- .../item/appearance/AppearanceStone.java | 55 ++++---- .../item/enchant/AbstractEnchantItem.java | 45 ++++--- .../gameserver/model/quest/LongTimeEvent.java | 4 +- .../gameserver/model/residences/ClanHall.java | 32 +++-- .../gameserver/model/siege/Castle.java | 6 +- .../serverpackets/BlockListPacket.java | 12 +- .../serverpackets/ExAcquireSkillInfo.java | 3 +- .../appearance/ExChooseShapeShiftingItem.java | 2 +- .../gameserver/util/DocumentBase.java | 37 ++--- .../scripts/handlers/bypasshandlers/Link.java | 94 ++++++------- .../handlers/itemhandlers/PetFood.java | 3 +- .../OpCheckResidenceSkillCondition.java | 7 +- .../OpNeedSummonOrPetSkillCondition.java | 28 ++-- .../OpTargetDoorSkillCondition.java | 7 +- .../OpTargetNpcSkillCondition.java | 9 +- .../scripts/instances/AbstractInstance.java | 19 ++- .../java/org/l2jmobius/Config.java | 32 ++--- .../gameserver/data/xml/ClanHallData.java | 3 +- .../gameserver/data/xml/FakePlayerData.java | 6 +- .../instancemanager/SellBuffsManager.java | 10 +- .../instancemanager/WalkingManager.java | 4 +- .../l2jmobius/gameserver/model/BlockList.java | 15 ++- .../l2jmobius/gameserver/model/PetData.java | 6 +- .../gameserver/model/SkillLearn.java | 27 ++-- .../gameserver/model/actor/instance/Pet.java | 3 +- .../gameserver/model/actor/instance/Trap.java | 6 +- .../model/actor/tasks/player/PetFeedTask.java | 5 +- .../ConditionPlayerInsideZoneId.java | 6 +- .../conditions/ConditionPlayerInstanceId.java | 6 +- .../model/conditions/ConditionPlayerRace.java | 9 +- .../ConditionPlayerRangeFromNpc.java | 11 +- .../ConditionPlayerRangeFromSummonedNpc.java | 11 +- .../ConditionTargetClassIdRestriction.java | 6 +- .../conditions/ConditionTargetNpcId.java | 6 +- .../model/holders/EventDropHolder.java | 8 +- .../gameserver/model/item/Henna.java | 8 +- .../item/appearance/AppearanceStone.java | 55 ++++---- .../item/enchant/AbstractEnchantItem.java | 49 +++---- .../gameserver/model/quest/LongTimeEvent.java | 4 +- .../gameserver/model/residences/ClanHall.java | 32 +++-- .../gameserver/model/siege/Castle.java | 6 +- .../serverpackets/BlockListPacket.java | 12 +- .../serverpackets/ExAcquireSkillInfo.java | 3 +- .../appearance/ExChooseShapeShiftingItem.java | 2 +- .../gameserver/util/DocumentBase.java | 37 ++--- .../scripts/handlers/bypasshandlers/Link.java | 126 +++++++++--------- .../handlers/itemhandlers/PetFood.java | 3 +- .../OpCheckResidenceSkillCondition.java | 7 +- .../OpNeedSummonOrPetSkillCondition.java | 28 ++-- .../OpTargetDoorSkillCondition.java | 7 +- .../OpTargetNpcSkillCondition.java | 9 +- .../scripts/instances/AbstractInstance.java | 19 ++- .../java/org/l2jmobius/Config.java | 32 ++--- .../gameserver/data/xml/ClanHallData.java | 3 +- .../gameserver/data/xml/FakePlayerData.java | 6 +- .../instancemanager/SellBuffsManager.java | 10 +- .../instancemanager/WalkingManager.java | 4 +- .../l2jmobius/gameserver/model/BlockList.java | 15 ++- .../l2jmobius/gameserver/model/PetData.java | 6 +- .../gameserver/model/SkillLearn.java | 27 ++-- .../gameserver/model/actor/instance/Pet.java | 3 +- .../gameserver/model/actor/instance/Trap.java | 6 +- .../model/actor/tasks/player/PetFeedTask.java | 5 +- .../ConditionPlayerInsideZoneId.java | 6 +- .../conditions/ConditionPlayerInstanceId.java | 6 +- .../model/conditions/ConditionPlayerRace.java | 9 +- .../ConditionPlayerRangeFromNpc.java | 11 +- .../ConditionPlayerRangeFromSummonedNpc.java | 11 +- .../ConditionTargetClassIdRestriction.java | 6 +- .../conditions/ConditionTargetNpcId.java | 6 +- .../model/holders/EventDropHolder.java | 8 +- .../gameserver/model/item/Henna.java | 8 +- .../item/appearance/AppearanceStone.java | 55 ++++---- .../item/enchant/AbstractEnchantItem.java | 49 +++---- .../gameserver/model/quest/LongTimeEvent.java | 4 +- .../gameserver/model/residences/ClanHall.java | 32 +++-- .../gameserver/model/siege/Castle.java | 6 +- .../serverpackets/BlockListPacket.java | 12 +- .../serverpackets/ExAcquireSkillInfo.java | 3 +- .../appearance/ExChooseShapeShiftingItem.java | 2 +- .../gameserver/util/DocumentBase.java | 37 ++--- .../scripts/handlers/bypasshandlers/Link.java | 126 +++++++++--------- .../handlers/itemhandlers/PetFood.java | 3 +- .../OpCheckResidenceSkillCondition.java | 7 +- .../OpNeedSummonOrPetSkillCondition.java | 28 ++-- .../OpTargetDoorSkillCondition.java | 7 +- .../OpTargetNpcSkillCondition.java | 9 +- .../scripts/instances/AbstractInstance.java | 19 ++- .../java/org/l2jmobius/Config.java | 32 ++--- .../gameserver/data/xml/ClanHallData.java | 3 +- .../gameserver/data/xml/FakePlayerData.java | 6 +- .../instancemanager/SellBuffsManager.java | 10 +- .../instancemanager/WalkingManager.java | 4 +- .../l2jmobius/gameserver/model/BlockList.java | 15 ++- .../l2jmobius/gameserver/model/PetData.java | 6 +- .../gameserver/model/SkillLearn.java | 27 ++-- .../gameserver/model/actor/instance/Pet.java | 3 +- .../gameserver/model/actor/instance/Trap.java | 6 +- .../model/actor/tasks/player/PetFeedTask.java | 5 +- .../ConditionPlayerInsideZoneId.java | 6 +- .../conditions/ConditionPlayerInstanceId.java | 6 +- .../model/conditions/ConditionPlayerRace.java | 9 +- .../ConditionPlayerRangeFromNpc.java | 11 +- .../ConditionPlayerRangeFromSummonedNpc.java | 11 +- .../ConditionTargetClassIdRestriction.java | 6 +- .../conditions/ConditionTargetNpcId.java | 6 +- .../model/holders/EventDropHolder.java | 8 +- .../gameserver/model/item/Henna.java | 8 +- .../item/appearance/AppearanceStone.java | 55 ++++---- .../item/enchant/AbstractEnchantItem.java | 49 +++---- .../gameserver/model/quest/LongTimeEvent.java | 4 +- .../gameserver/model/residences/ClanHall.java | 32 +++-- .../gameserver/model/siege/Castle.java | 6 +- .../serverpackets/BlockListPacket.java | 12 +- .../serverpackets/ExAcquireSkillInfo.java | 3 +- .../appearance/ExChooseShapeShiftingItem.java | 2 +- .../gameserver/util/DocumentBase.java | 37 ++--- .../scripts/handlers/bypasshandlers/Link.java | 126 +++++++++--------- .../MonsterDailyMissionHandler.java | 5 +- .../handlers/itemhandlers/PetFood.java | 3 +- .../OpCheckResidenceSkillCondition.java | 7 +- .../OpNeedSummonOrPetSkillCondition.java | 28 ++-- .../OpTargetDoorSkillCondition.java | 7 +- .../OpTargetNpcSkillCondition.java | 9 +- .../scripts/instances/AbstractInstance.java | 19 ++- .../java/org/l2jmobius/Config.java | 32 ++--- .../gameserver/data/xml/ClanHallData.java | 3 +- .../gameserver/data/xml/FakePlayerData.java | 6 +- .../instancemanager/SellBuffsManager.java | 10 +- .../instancemanager/WalkingManager.java | 4 +- .../l2jmobius/gameserver/model/BlockList.java | 15 ++- .../l2jmobius/gameserver/model/PetData.java | 6 +- .../gameserver/model/SkillLearn.java | 27 ++-- .../gameserver/model/actor/instance/Pet.java | 3 +- .../gameserver/model/actor/instance/Trap.java | 6 +- .../model/actor/tasks/player/PetFeedTask.java | 5 +- .../ConditionPlayerInsideZoneId.java | 6 +- .../conditions/ConditionPlayerInstanceId.java | 6 +- .../model/conditions/ConditionPlayerRace.java | 9 +- .../ConditionPlayerRangeFromNpc.java | 11 +- .../ConditionPlayerRangeFromSummonedNpc.java | 11 +- .../ConditionTargetClassIdRestriction.java | 6 +- .../conditions/ConditionTargetNpcId.java | 6 +- .../model/holders/EventDropHolder.java | 8 +- .../gameserver/model/item/Henna.java | 8 +- .../item/appearance/AppearanceStone.java | 55 ++++---- .../item/enchant/AbstractEnchantItem.java | 49 +++---- .../gameserver/model/quest/LongTimeEvent.java | 4 +- .../gameserver/model/residences/ClanHall.java | 32 +++-- .../gameserver/model/siege/Castle.java | 6 +- .../serverpackets/BlockListPacket.java | 12 +- .../serverpackets/ExAcquireSkillInfo.java | 3 +- .../appearance/ExChooseShapeShiftingItem.java | 2 +- .../gameserver/util/DocumentBase.java | 37 ++--- .../scripts/handlers/bypasshandlers/Link.java | 126 +++++++++--------- .../MonsterDailyMissionHandler.java | 5 +- .../handlers/itemhandlers/PetFood.java | 3 +- .../OpCheckResidenceSkillCondition.java | 7 +- .../OpNeedSummonOrPetSkillCondition.java | 28 ++-- .../OpTargetDoorSkillCondition.java | 7 +- .../OpTargetNpcSkillCondition.java | 9 +- .../scripts/instances/AbstractInstance.java | 19 ++- .../java/org/l2jmobius/Config.java | 32 ++--- .../gameserver/data/xml/ClanHallData.java | 3 +- .../gameserver/data/xml/FakePlayerData.java | 6 +- .../instancemanager/SellBuffsManager.java | 10 +- .../instancemanager/WalkingManager.java | 4 +- .../l2jmobius/gameserver/model/BlockList.java | 15 ++- .../l2jmobius/gameserver/model/PetData.java | 6 +- .../gameserver/model/SkillLearn.java | 27 ++-- .../gameserver/model/actor/instance/Pet.java | 3 +- .../gameserver/model/actor/instance/Trap.java | 6 +- .../model/actor/tasks/player/PetFeedTask.java | 5 +- .../ConditionPlayerInsideZoneId.java | 6 +- .../conditions/ConditionPlayerInstanceId.java | 6 +- .../model/conditions/ConditionPlayerRace.java | 9 +- .../ConditionPlayerRangeFromNpc.java | 11 +- .../ConditionPlayerRangeFromSummonedNpc.java | 11 +- .../ConditionTargetClassIdRestriction.java | 6 +- .../conditions/ConditionTargetNpcId.java | 6 +- .../model/holders/EventDropHolder.java | 8 +- .../gameserver/model/item/Henna.java | 8 +- .../item/appearance/AppearanceStone.java | 55 ++++---- .../item/enchant/AbstractEnchantItem.java | 49 +++---- .../gameserver/model/quest/LongTimeEvent.java | 4 +- .../gameserver/model/residences/ClanHall.java | 32 +++-- .../gameserver/model/siege/Castle.java | 6 +- .../serverpackets/BlockListPacket.java | 12 +- .../serverpackets/ExAcquireSkillInfo.java | 3 +- .../appearance/ExChooseShapeShiftingItem.java | 2 +- .../gameserver/util/DocumentBase.java | 37 ++--- .../scripts/handlers/bypasshandlers/Link.java | 98 +++++++------- .../MonsterDailyMissionHandler.java | 5 +- .../handlers/itemhandlers/PetFood.java | 3 +- .../OpCheckResidenceSkillCondition.java | 7 +- .../OpNeedSummonOrPetSkillCondition.java | 28 ++-- .../OpTargetDoorSkillCondition.java | 7 +- .../OpTargetNpcSkillCondition.java | 9 +- .../scripts/instances/AbstractInstance.java | 19 ++- .../java/org/l2jmobius/Config.java | 32 ++--- .../gameserver/data/xml/ClanHallData.java | 3 +- .../gameserver/data/xml/FakePlayerData.java | 6 +- .../gameserver/data/xml/VariationData.java | 14 +- .../instancemanager/SellBuffsManager.java | 10 +- .../instancemanager/WalkingManager.java | 4 +- .../l2jmobius/gameserver/model/BlockList.java | 15 ++- .../l2jmobius/gameserver/model/PetData.java | 6 +- .../gameserver/model/SkillLearn.java | 27 ++-- .../gameserver/model/actor/instance/Pet.java | 3 +- .../gameserver/model/actor/instance/Trap.java | 6 +- .../model/actor/tasks/player/PetFeedTask.java | 5 +- .../ConditionPlayerInsideZoneId.java | 6 +- .../conditions/ConditionPlayerInstanceId.java | 6 +- .../model/conditions/ConditionPlayerRace.java | 9 +- .../ConditionPlayerRangeFromNpc.java | 11 +- .../ConditionPlayerRangeFromSummonedNpc.java | 11 +- .../ConditionTargetClassIdRestriction.java | 6 +- .../conditions/ConditionTargetNpcId.java | 6 +- .../model/holders/EventDropHolder.java | 8 +- .../gameserver/model/item/Henna.java | 8 +- .../item/appearance/AppearanceStone.java | 55 ++++---- .../item/enchant/AbstractEnchantItem.java | 49 +++---- .../model/options/OptionDataCategory.java | 8 +- .../gameserver/model/quest/LongTimeEvent.java | 4 +- .../gameserver/model/residences/ClanHall.java | 32 +++-- .../gameserver/model/siege/Castle.java | 6 +- .../serverpackets/BlockListPacket.java | 12 +- .../serverpackets/ExAcquireSkillInfo.java | 3 +- .../appearance/ExChooseShapeShiftingItem.java | 2 +- .../gameserver/util/DocumentBase.java | 37 ++--- .../scripts/handlers/bypasshandlers/Link.java | 98 +++++++------- .../MonsterDailyMissionHandler.java | 5 +- .../handlers/itemhandlers/PetFood.java | 3 +- .../OpCheckResidenceSkillCondition.java | 7 +- .../OpNeedSummonOrPetSkillCondition.java | 28 ++-- .../OpTargetDoorSkillCondition.java | 7 +- .../OpTargetNpcSkillCondition.java | 9 +- .../scripts/instances/AbstractInstance.java | 19 ++- .../java/org/l2jmobius/Config.java | 32 ++--- .../gameserver/data/xml/ClanHallData.java | 3 +- .../gameserver/data/xml/FakePlayerData.java | 6 +- .../gameserver/data/xml/VariationData.java | 14 +- .../instancemanager/SellBuffsManager.java | 10 +- .../instancemanager/WalkingManager.java | 4 +- .../l2jmobius/gameserver/model/BlockList.java | 15 ++- .../l2jmobius/gameserver/model/PetData.java | 6 +- .../gameserver/model/SkillLearn.java | 27 ++-- .../gameserver/model/actor/instance/Pet.java | 3 +- .../gameserver/model/actor/instance/Trap.java | 6 +- .../model/actor/tasks/player/PetFeedTask.java | 5 +- .../ConditionPlayerInsideZoneId.java | 6 +- .../conditions/ConditionPlayerInstanceId.java | 6 +- .../model/conditions/ConditionPlayerRace.java | 9 +- .../ConditionPlayerRangeFromNpc.java | 11 +- .../ConditionPlayerRangeFromSummonedNpc.java | 11 +- .../ConditionTargetClassIdRestriction.java | 6 +- .../conditions/ConditionTargetNpcId.java | 6 +- .../model/holders/EventDropHolder.java | 8 +- .../gameserver/model/item/Henna.java | 8 +- .../item/appearance/AppearanceStone.java | 55 ++++---- .../item/enchant/AbstractEnchantItem.java | 49 +++---- .../model/options/OptionDataCategory.java | 8 +- .../gameserver/model/quest/LongTimeEvent.java | 4 +- .../gameserver/model/residences/ClanHall.java | 32 +++-- .../gameserver/model/siege/Castle.java | 6 +- .../serverpackets/BlockListPacket.java | 12 +- .../serverpackets/ExAcquireSkillInfo.java | 3 +- .../appearance/ExChooseShapeShiftingItem.java | 2 +- .../gameserver/util/DocumentBase.java | 37 ++--- .../scripts/handlers/bypasshandlers/Link.java | 98 +++++++------- .../MonsterDailyMissionHandler.java | 5 +- .../handlers/itemhandlers/PetFood.java | 3 +- .../OpCheckResidenceSkillCondition.java | 7 +- .../OpNeedSummonOrPetSkillCondition.java | 28 ++-- .../OpTargetDoorSkillCondition.java | 7 +- .../OpTargetNpcSkillCondition.java | 9 +- .../scripts/instances/AbstractInstance.java | 19 ++- .../java/org/l2jmobius/Config.java | 32 ++--- .../gameserver/data/xml/ClanHallData.java | 3 +- .../gameserver/data/xml/FakePlayerData.java | 6 +- .../gameserver/data/xml/VariationData.java | 14 +- .../instancemanager/SellBuffsManager.java | 10 +- .../instancemanager/WalkingManager.java | 4 +- .../l2jmobius/gameserver/model/BlockList.java | 15 ++- .../l2jmobius/gameserver/model/PetData.java | 6 +- .../gameserver/model/SkillLearn.java | 27 ++-- .../gameserver/model/actor/instance/Pet.java | 3 +- .../gameserver/model/actor/instance/Trap.java | 6 +- .../model/actor/tasks/player/PetFeedTask.java | 5 +- .../ConditionPlayerInsideZoneId.java | 6 +- .../conditions/ConditionPlayerInstanceId.java | 6 +- .../model/conditions/ConditionPlayerRace.java | 9 +- .../ConditionPlayerRangeFromNpc.java | 11 +- .../ConditionPlayerRangeFromSummonedNpc.java | 11 +- .../ConditionTargetClassIdRestriction.java | 6 +- .../conditions/ConditionTargetNpcId.java | 6 +- .../model/holders/EventDropHolder.java | 8 +- .../gameserver/model/item/Henna.java | 8 +- .../item/appearance/AppearanceStone.java | 55 ++++---- .../item/enchant/AbstractEnchantItem.java | 49 +++---- .../model/options/OptionDataCategory.java | 8 +- .../gameserver/model/quest/LongTimeEvent.java | 4 +- .../gameserver/model/residences/ClanHall.java | 32 +++-- .../gameserver/model/siege/Castle.java | 6 +- .../serverpackets/BlockListPacket.java | 12 +- .../serverpackets/ExAcquireSkillInfo.java | 3 +- .../appearance/ExChooseShapeShiftingItem.java | 2 +- .../gameserver/util/DocumentBase.java | 37 ++--- .../java/org/l2jmobius/Config.java | 6 +- .../java/org/l2jmobius/Config.java | 56 ++++---- .../Manager/FriendsBBSManager.java | 3 +- .../l2jmobius/gameserver/model/BlockList.java | 89 ++++++------- .../model/holders/EventDropHolder.java | 8 +- .../gameserver/model/quest/LongTimeEvent.java | 4 +- .../java/org/l2jmobius/Config.java | 56 ++++---- .../Manager/FriendsBBSManager.java | 3 +- .../l2jmobius/gameserver/model/BlockList.java | 89 ++++++------- .../model/holders/EventDropHolder.java | 8 +- .../gameserver/model/quest/LongTimeEvent.java | 4 +- .../scripts/handlers/bypasshandlers/Link.java | 94 ++++++------- .../handlers/itemhandlers/PetFood.java | 15 +-- .../java/org/l2jmobius/Config.java | 32 ++--- .../gameserver/data/xml/FakePlayerData.java | 6 +- .../gameserver/data/xml/SkillTreeData.java | 2 +- .../instancemanager/SellBuffsManager.java | 10 +- .../instancemanager/WalkingManager.java | 4 +- .../l2jmobius/gameserver/model/BlockList.java | 15 ++- .../l2jmobius/gameserver/model/PetData.java | 6 +- .../gameserver/model/SkillLearn.java | 29 ++-- .../gameserver/model/actor/instance/Pet.java | 3 +- .../gameserver/model/actor/instance/Trap.java | 6 +- .../model/actor/tasks/player/PetFeedTask.java | 4 +- .../ConditionPlayerInsideZoneId.java | 6 +- .../conditions/ConditionPlayerInstanceId.java | 6 +- .../model/conditions/ConditionPlayerRace.java | 13 +- .../ConditionPlayerRangeFromNpc.java | 11 +- .../ConditionTargetClassIdRestriction.java | 6 +- .../conditions/ConditionTargetNpcId.java | 6 +- .../model/holders/EventDropHolder.java | 8 +- .../gameserver/model/item/Henna.java | 9 +- .../item/enchant/AbstractEnchantItem.java | 29 ++-- .../gameserver/model/quest/LongTimeEvent.java | 4 +- .../gameserver/model/siege/Castle.java | 12 +- .../gameserver/util/DocumentBase.java | 33 ++--- .../scripts/handlers/bypasshandlers/Link.java | 94 ++++++------- .../handlers/itemhandlers/PetFood.java | 15 +-- .../java/org/l2jmobius/Config.java | 32 ++--- .../gameserver/data/xml/FakePlayerData.java | 6 +- .../gameserver/data/xml/SkillTreeData.java | 2 +- .../instancemanager/SellBuffsManager.java | 10 +- .../instancemanager/WalkingManager.java | 4 +- .../l2jmobius/gameserver/model/BlockList.java | 15 ++- .../l2jmobius/gameserver/model/PetData.java | 6 +- .../gameserver/model/SkillLearn.java | 29 ++-- .../gameserver/model/actor/instance/Pet.java | 3 +- .../gameserver/model/actor/instance/Trap.java | 6 +- .../model/actor/tasks/player/PetFeedTask.java | 4 +- .../ConditionPlayerInsideZoneId.java | 6 +- .../conditions/ConditionPlayerInstanceId.java | 6 +- .../model/conditions/ConditionPlayerRace.java | 13 +- .../ConditionPlayerRangeFromNpc.java | 11 +- .../ConditionTargetClassIdRestriction.java | 6 +- .../conditions/ConditionTargetNpcId.java | 6 +- .../model/holders/EventDropHolder.java | 8 +- .../gameserver/model/item/Henna.java | 9 +- .../item/enchant/AbstractEnchantItem.java | 29 ++-- .../gameserver/model/quest/LongTimeEvent.java | 4 +- .../gameserver/model/siege/Castle.java | 12 +- .../gameserver/util/DocumentBase.java | 33 ++--- .../scripts/handlers/bypasshandlers/Link.java | 68 +++++----- .../handlers/itemhandlers/PetFood.java | 3 +- .../OpCheckResidenceSkillCondition.java | 7 +- .../OpNeedSummonOrPetSkillCondition.java | 28 ++-- .../OpTargetDoorSkillCondition.java | 7 +- .../OpTargetNpcSkillCondition.java | 9 +- .../scripts/instances/AbstractInstance.java | 19 ++- .../java/org/l2jmobius/Config.java | 32 ++--- .../gameserver/data/xml/ClanHallData.java | 3 +- .../gameserver/data/xml/FakePlayerData.java | 6 +- .../instancemanager/SellBuffsManager.java | 10 +- .../instancemanager/WalkingManager.java | 4 +- .../l2jmobius/gameserver/model/BlockList.java | 15 ++- .../l2jmobius/gameserver/model/PetData.java | 6 +- .../gameserver/model/SkillLearn.java | 27 ++-- .../gameserver/model/actor/instance/Pet.java | 3 +- .../gameserver/model/actor/instance/Trap.java | 6 +- .../model/actor/tasks/player/PetFeedTask.java | 5 +- .../ConditionPlayerInsideZoneId.java | 6 +- .../conditions/ConditionPlayerInstanceId.java | 6 +- .../model/conditions/ConditionPlayerRace.java | 9 +- .../ConditionPlayerRangeFromNpc.java | 11 +- .../ConditionPlayerRangeFromSummonedNpc.java | 11 +- .../ConditionTargetClassIdRestriction.java | 6 +- .../conditions/ConditionTargetNpcId.java | 6 +- .../model/holders/EventDropHolder.java | 8 +- .../gameserver/model/item/Henna.java | 12 +- .../item/appearance/AppearanceStone.java | 55 ++++---- .../item/enchant/AbstractEnchantItem.java | 45 ++++--- .../gameserver/model/quest/LongTimeEvent.java | 4 +- .../gameserver/model/residences/ClanHall.java | 32 +++-- .../gameserver/model/siege/Castle.java | 6 +- .../serverpackets/BlockListPacket.java | 12 +- .../serverpackets/ExAcquireSkillInfo.java | 3 +- .../appearance/ExChooseShapeShiftingItem.java | 2 +- .../gameserver/util/DocumentBase.java | 37 ++--- .../scripts/handlers/bypasshandlers/Link.java | 68 +++++----- .../handlers/itemhandlers/PetFood.java | 3 +- .../OpCheckResidenceSkillCondition.java | 7 +- .../OpNeedSummonOrPetSkillCondition.java | 28 ++-- .../OpTargetDoorSkillCondition.java | 7 +- .../OpTargetNpcSkillCondition.java | 9 +- .../scripts/instances/AbstractInstance.java | 19 ++- .../java/org/l2jmobius/Config.java | 32 ++--- .../gameserver/data/xml/ClanHallData.java | 3 +- .../gameserver/data/xml/FakePlayerData.java | 6 +- .../instancemanager/SellBuffsManager.java | 10 +- .../instancemanager/WalkingManager.java | 4 +- .../l2jmobius/gameserver/model/BlockList.java | 15 ++- .../l2jmobius/gameserver/model/PetData.java | 6 +- .../gameserver/model/SkillLearn.java | 27 ++-- .../gameserver/model/actor/instance/Pet.java | 3 +- .../gameserver/model/actor/instance/Trap.java | 6 +- .../model/actor/tasks/player/PetFeedTask.java | 5 +- .../ConditionPlayerInsideZoneId.java | 6 +- .../conditions/ConditionPlayerInstanceId.java | 6 +- .../model/conditions/ConditionPlayerRace.java | 9 +- .../ConditionPlayerRangeFromNpc.java | 11 +- .../ConditionPlayerRangeFromSummonedNpc.java | 11 +- .../ConditionTargetClassIdRestriction.java | 6 +- .../conditions/ConditionTargetNpcId.java | 6 +- .../model/holders/EventDropHolder.java | 8 +- .../gameserver/model/item/Henna.java | 12 +- .../item/appearance/AppearanceStone.java | 55 ++++---- .../item/enchant/AbstractEnchantItem.java | 45 ++++--- .../gameserver/model/quest/LongTimeEvent.java | 4 +- .../gameserver/model/residences/ClanHall.java | 32 +++-- .../gameserver/model/siege/Castle.java | 6 +- .../serverpackets/BlockListPacket.java | 12 +- .../serverpackets/ExAcquireSkillInfo.java | 3 +- .../appearance/ExChooseShapeShiftingItem.java | 2 +- .../gameserver/util/DocumentBase.java | 37 ++--- .../scripts/handlers/bypasshandlers/Link.java | 68 +++++----- .../handlers/itemhandlers/PetFood.java | 3 +- .../OpCheckResidenceSkillCondition.java | 7 +- .../OpNeedSummonOrPetSkillCondition.java | 28 ++-- .../OpTargetDoorSkillCondition.java | 7 +- .../OpTargetNpcSkillCondition.java | 9 +- .../scripts/instances/AbstractInstance.java | 19 ++- .../java/org/l2jmobius/Config.java | 32 ++--- .../gameserver/data/xml/ClanHallData.java | 3 +- .../gameserver/data/xml/FakePlayerData.java | 6 +- .../instancemanager/SellBuffsManager.java | 10 +- .../instancemanager/WalkingManager.java | 4 +- .../l2jmobius/gameserver/model/BlockList.java | 15 ++- .../l2jmobius/gameserver/model/PetData.java | 6 +- .../gameserver/model/SkillLearn.java | 27 ++-- .../gameserver/model/actor/instance/Pet.java | 3 +- .../gameserver/model/actor/instance/Trap.java | 6 +- .../model/actor/tasks/player/PetFeedTask.java | 5 +- .../ConditionPlayerInsideZoneId.java | 6 +- .../conditions/ConditionPlayerInstanceId.java | 6 +- .../model/conditions/ConditionPlayerRace.java | 9 +- .../ConditionPlayerRangeFromNpc.java | 11 +- .../ConditionPlayerRangeFromSummonedNpc.java | 11 +- .../ConditionTargetClassIdRestriction.java | 6 +- .../conditions/ConditionTargetNpcId.java | 6 +- .../model/holders/EventDropHolder.java | 8 +- .../gameserver/model/item/Henna.java | 12 +- .../item/appearance/AppearanceStone.java | 55 ++++---- .../item/enchant/AbstractEnchantItem.java | 45 ++++--- .../gameserver/model/quest/LongTimeEvent.java | 4 +- .../gameserver/model/residences/ClanHall.java | 32 +++-- .../gameserver/model/siege/Castle.java | 6 +- .../serverpackets/BlockListPacket.java | 12 +- .../serverpackets/ExAcquireSkillInfo.java | 3 +- .../appearance/ExChooseShapeShiftingItem.java | 2 +- .../gameserver/util/DocumentBase.java | 37 ++--- .../scripts/handlers/bypasshandlers/Link.java | 68 +++++----- .../handlers/itemhandlers/PetFood.java | 3 +- .../OpCheckResidenceSkillCondition.java | 7 +- .../OpNeedSummonOrPetSkillCondition.java | 28 ++-- .../OpTargetDoorSkillCondition.java | 7 +- .../OpTargetNpcSkillCondition.java | 9 +- .../scripts/instances/AbstractInstance.java | 19 ++- .../java/org/l2jmobius/Config.java | 32 ++--- .../gameserver/data/xml/ClanHallData.java | 3 +- .../gameserver/data/xml/FakePlayerData.java | 6 +- .../instancemanager/SellBuffsManager.java | 10 +- .../instancemanager/WalkingManager.java | 4 +- .../l2jmobius/gameserver/model/BlockList.java | 15 ++- .../l2jmobius/gameserver/model/PetData.java | 6 +- .../gameserver/model/SkillLearn.java | 27 ++-- .../gameserver/model/actor/instance/Pet.java | 3 +- .../gameserver/model/actor/instance/Trap.java | 6 +- .../model/actor/tasks/player/PetFeedTask.java | 5 +- .../ConditionPlayerInsideZoneId.java | 6 +- .../conditions/ConditionPlayerInstanceId.java | 6 +- .../model/conditions/ConditionPlayerRace.java | 9 +- .../ConditionPlayerRangeFromNpc.java | 11 +- .../ConditionPlayerRangeFromSummonedNpc.java | 11 +- .../ConditionTargetClassIdRestriction.java | 6 +- .../conditions/ConditionTargetNpcId.java | 6 +- .../model/holders/EventDropHolder.java | 8 +- .../gameserver/model/item/Henna.java | 12 +- .../item/appearance/AppearanceStone.java | 55 ++++---- .../item/enchant/AbstractEnchantItem.java | 45 ++++--- .../gameserver/model/quest/LongTimeEvent.java | 4 +- .../gameserver/model/residences/ClanHall.java | 32 +++-- .../gameserver/model/siege/Castle.java | 6 +- .../serverpackets/BlockListPacket.java | 12 +- .../serverpackets/ExAcquireSkillInfo.java | 3 +- .../appearance/ExChooseShapeShiftingItem.java | 2 +- .../gameserver/util/DocumentBase.java | 37 ++--- .../scripts/handlers/bypasshandlers/Link.java | 68 +++++----- .../MonsterDailyMissionHandler.java | 5 +- .../handlers/itemhandlers/PetFood.java | 3 +- .../OpCheckResidenceSkillCondition.java | 7 +- .../OpNeedSummonOrPetSkillCondition.java | 28 ++-- .../OpTargetDoorSkillCondition.java | 7 +- .../OpTargetNpcSkillCondition.java | 9 +- .../scripts/instances/AbstractInstance.java | 19 ++- .../java/org/l2jmobius/Config.java | 32 ++--- .../gameserver/data/xml/ClanHallData.java | 3 +- .../gameserver/data/xml/FakePlayerData.java | 6 +- .../instancemanager/SellBuffsManager.java | 10 +- .../instancemanager/WalkingManager.java | 4 +- .../l2jmobius/gameserver/model/BlockList.java | 15 ++- .../l2jmobius/gameserver/model/PetData.java | 6 +- .../gameserver/model/SkillLearn.java | 27 ++-- .../gameserver/model/actor/instance/Pet.java | 3 +- .../gameserver/model/actor/instance/Trap.java | 6 +- .../model/actor/tasks/player/PetFeedTask.java | 5 +- .../ConditionPlayerInsideZoneId.java | 6 +- .../conditions/ConditionPlayerInstanceId.java | 6 +- .../model/conditions/ConditionPlayerRace.java | 9 +- .../ConditionPlayerRangeFromNpc.java | 11 +- .../ConditionPlayerRangeFromSummonedNpc.java | 11 +- .../ConditionTargetClassIdRestriction.java | 6 +- .../conditions/ConditionTargetNpcId.java | 6 +- .../model/holders/EventDropHolder.java | 8 +- .../gameserver/model/item/Henna.java | 12 +- .../item/appearance/AppearanceStone.java | 55 ++++---- .../item/enchant/AbstractEnchantItem.java | 45 ++++--- .../gameserver/model/quest/LongTimeEvent.java | 4 +- .../gameserver/model/residences/ClanHall.java | 32 +++-- .../gameserver/model/siege/Castle.java | 6 +- .../serverpackets/BlockListPacket.java | 12 +- .../serverpackets/ExAcquireSkillInfo.java | 3 +- .../appearance/ExChooseShapeShiftingItem.java | 2 +- .../gameserver/util/DocumentBase.java | 37 ++--- .../scripts/handlers/bypasshandlers/Link.java | 68 +++++----- .../MonsterDailyMissionHandler.java | 5 +- .../handlers/itemhandlers/PetFood.java | 3 +- .../OpCheckResidenceSkillCondition.java | 7 +- .../OpNeedSummonOrPetSkillCondition.java | 28 ++-- .../OpTargetDoorSkillCondition.java | 7 +- .../OpTargetNpcSkillCondition.java | 9 +- .../scripts/instances/AbstractInstance.java | 19 ++- .../java/org/l2jmobius/Config.java | 32 ++--- .../gameserver/data/xml/ClanHallData.java | 3 +- .../gameserver/data/xml/FakePlayerData.java | 6 +- .../instancemanager/SellBuffsManager.java | 10 +- .../instancemanager/WalkingManager.java | 4 +- .../l2jmobius/gameserver/model/BlockList.java | 15 ++- .../l2jmobius/gameserver/model/PetData.java | 6 +- .../gameserver/model/SkillLearn.java | 27 ++-- .../gameserver/model/actor/instance/Pet.java | 3 +- .../gameserver/model/actor/instance/Trap.java | 6 +- .../model/actor/tasks/player/PetFeedTask.java | 5 +- .../ConditionPlayerInsideZoneId.java | 6 +- .../conditions/ConditionPlayerInstanceId.java | 6 +- .../model/conditions/ConditionPlayerRace.java | 9 +- .../ConditionPlayerRangeFromNpc.java | 11 +- .../ConditionPlayerRangeFromSummonedNpc.java | 11 +- .../ConditionTargetClassIdRestriction.java | 6 +- .../conditions/ConditionTargetNpcId.java | 6 +- .../model/holders/EventDropHolder.java | 8 +- .../gameserver/model/item/Henna.java | 12 +- .../item/appearance/AppearanceStone.java | 55 ++++---- .../item/enchant/AbstractEnchantItem.java | 45 ++++--- .../gameserver/model/quest/LongTimeEvent.java | 4 +- .../gameserver/model/residences/ClanHall.java | 32 +++-- .../gameserver/model/siege/Castle.java | 6 +- .../serverpackets/BlockListPacket.java | 12 +- .../serverpackets/ExAcquireSkillInfo.java | 3 +- .../appearance/ExChooseShapeShiftingItem.java | 2 +- .../gameserver/util/DocumentBase.java | 37 ++--- .../scripts/handlers/bypasshandlers/Link.java | 58 ++++---- .../handlers/itemhandlers/PetFood.java | 3 +- .../OpCheckResidenceSkillCondition.java | 7 +- .../OpNeedSummonOrPetSkillCondition.java | 28 ++-- .../OpTargetDoorSkillCondition.java | 7 +- .../OpTargetNpcSkillCondition.java | 9 +- .../scripts/instances/AbstractInstance.java | 19 ++- .../java/org/l2jmobius/Config.java | 32 ++--- .../gameserver/data/xml/ClanHallData.java | 3 +- .../gameserver/data/xml/FakePlayerData.java | 6 +- .../instancemanager/SellBuffsManager.java | 10 +- .../instancemanager/WalkingManager.java | 4 +- .../l2jmobius/gameserver/model/BlockList.java | 15 ++- .../l2jmobius/gameserver/model/PetData.java | 6 +- .../gameserver/model/SkillLearn.java | 27 ++-- .../gameserver/model/actor/instance/Pet.java | 3 +- .../gameserver/model/actor/instance/Trap.java | 6 +- .../model/actor/tasks/player/PetFeedTask.java | 5 +- .../ConditionPlayerInsideZoneId.java | 6 +- .../conditions/ConditionPlayerInstanceId.java | 6 +- .../model/conditions/ConditionPlayerRace.java | 9 +- .../ConditionPlayerRangeFromNpc.java | 11 +- .../ConditionPlayerRangeFromSummonedNpc.java | 11 +- .../ConditionTargetClassIdRestriction.java | 6 +- .../conditions/ConditionTargetNpcId.java | 6 +- .../model/holders/EventDropHolder.java | 8 +- .../gameserver/model/item/Henna.java | 12 +- .../item/appearance/AppearanceStone.java | 55 ++++---- .../item/enchant/AbstractEnchantItem.java | 45 ++++--- .../gameserver/model/quest/LongTimeEvent.java | 4 +- .../gameserver/model/residences/ClanHall.java | 32 +++-- .../gameserver/model/siege/Castle.java | 6 +- .../serverpackets/BlockListPacket.java | 12 +- .../serverpackets/ExAcquireSkillInfo.java | 3 +- .../appearance/ExChooseShapeShiftingItem.java | 2 +- .../gameserver/util/DocumentBase.java | 37 ++--- .../scripts/handlers/bypasshandlers/Link.java | 50 +++---- .../MonsterDailyMissionHandler.java | 5 +- .../handlers/itemhandlers/PetFood.java | 3 +- .../OpCheckResidenceSkillCondition.java | 7 +- .../OpNeedSummonOrPetSkillCondition.java | 28 ++-- .../OpTargetDoorSkillCondition.java | 7 +- .../OpTargetNpcSkillCondition.java | 9 +- .../scripts/instances/AbstractInstance.java | 19 ++- .../java/org/l2jmobius/Config.java | 32 ++--- .../gameserver/data/xml/ClanHallData.java | 3 +- .../gameserver/data/xml/FakePlayerData.java | 6 +- .../gameserver/data/xml/VariationData.java | 14 +- .../instancemanager/SellBuffsManager.java | 10 +- .../instancemanager/WalkingManager.java | 4 +- .../l2jmobius/gameserver/model/BlockList.java | 15 ++- .../l2jmobius/gameserver/model/PetData.java | 6 +- .../gameserver/model/SkillLearn.java | 27 ++-- .../gameserver/model/actor/instance/Pet.java | 2 +- .../gameserver/model/actor/instance/Trap.java | 6 +- .../model/actor/tasks/player/PetFeedTask.java | 5 +- .../ConditionPlayerInsideZoneId.java | 6 +- .../conditions/ConditionPlayerInstanceId.java | 6 +- .../model/conditions/ConditionPlayerRace.java | 9 +- .../ConditionPlayerRangeFromNpc.java | 11 +- .../ConditionPlayerRangeFromSummonedNpc.java | 11 +- .../ConditionTargetClassIdRestriction.java | 6 +- .../conditions/ConditionTargetNpcId.java | 6 +- .../model/holders/EventDropHolder.java | 8 +- .../gameserver/model/item/Henna.java | 12 +- .../item/appearance/AppearanceStone.java | 55 ++++---- .../item/enchant/AbstractEnchantItem.java | 49 +++---- .../model/options/OptionDataCategory.java | 8 +- .../gameserver/model/quest/LongTimeEvent.java | 4 +- .../gameserver/model/residences/ClanHall.java | 32 +++-- .../gameserver/model/siege/Castle.java | 6 +- .../serverpackets/BlockListPacket.java | 12 +- .../serverpackets/ExAcquireSkillInfo.java | 3 +- .../appearance/ExChooseShapeShiftingItem.java | 2 +- .../gameserver/util/DocumentBase.java | 37 ++--- .../scripts/handlers/bypasshandlers/Link.java | 50 +++---- .../MonsterDailyMissionHandler.java | 5 +- .../handlers/itemhandlers/PetFood.java | 3 +- .../OpCheckResidenceSkillCondition.java | 7 +- .../OpNeedSummonOrPetSkillCondition.java | 28 ++-- .../OpTargetDoorSkillCondition.java | 7 +- .../OpTargetNpcSkillCondition.java | 9 +- .../scripts/instances/AbstractInstance.java | 19 ++- .../java/org/l2jmobius/Config.java | 32 ++--- .../gameserver/data/xml/ClanHallData.java | 3 +- .../gameserver/data/xml/FakePlayerData.java | 6 +- .../gameserver/data/xml/VariationData.java | 14 +- .../instancemanager/SellBuffsManager.java | 10 +- .../instancemanager/WalkingManager.java | 4 +- .../l2jmobius/gameserver/model/BlockList.java | 15 ++- .../l2jmobius/gameserver/model/PetData.java | 6 +- .../gameserver/model/SkillLearn.java | 27 ++-- .../gameserver/model/actor/instance/Pet.java | 2 +- .../gameserver/model/actor/instance/Trap.java | 6 +- .../model/actor/tasks/player/PetFeedTask.java | 5 +- .../ConditionPlayerInsideZoneId.java | 6 +- .../conditions/ConditionPlayerInstanceId.java | 6 +- .../model/conditions/ConditionPlayerRace.java | 9 +- .../ConditionPlayerRangeFromNpc.java | 11 +- .../ConditionPlayerRangeFromSummonedNpc.java | 11 +- .../ConditionTargetClassIdRestriction.java | 6 +- .../conditions/ConditionTargetNpcId.java | 6 +- .../model/holders/EventDropHolder.java | 8 +- .../gameserver/model/item/Henna.java | 12 +- .../item/appearance/AppearanceStone.java | 55 ++++---- .../item/enchant/AbstractEnchantItem.java | 49 +++---- .../model/options/OptionDataCategory.java | 8 +- .../gameserver/model/quest/LongTimeEvent.java | 4 +- .../gameserver/model/residences/ClanHall.java | 32 +++-- .../gameserver/model/siege/Castle.java | 6 +- .../serverpackets/BlockListPacket.java | 12 +- .../serverpackets/ExAcquireSkillInfo.java | 3 +- .../appearance/ExChooseShapeShiftingItem.java | 2 +- .../gameserver/util/DocumentBase.java | 37 ++--- .../scripts/handlers/bypasshandlers/Link.java | 50 +++---- .../MonsterDailyMissionHandler.java | 5 +- .../handlers/itemhandlers/PetFood.java | 3 +- .../OpCheckResidenceSkillCondition.java | 7 +- .../OpNeedSummonOrPetSkillCondition.java | 28 ++-- .../OpTargetDoorSkillCondition.java | 7 +- .../OpTargetNpcSkillCondition.java | 9 +- .../scripts/instances/AbstractInstance.java | 19 ++- .../java/org/l2jmobius/Config.java | 32 ++--- .../gameserver/data/xml/ClanHallData.java | 3 +- .../gameserver/data/xml/FakePlayerData.java | 6 +- .../gameserver/data/xml/VariationData.java | 14 +- .../instancemanager/SellBuffsManager.java | 10 +- .../instancemanager/WalkingManager.java | 4 +- .../l2jmobius/gameserver/model/BlockList.java | 15 ++- .../l2jmobius/gameserver/model/PetData.java | 6 +- .../gameserver/model/SkillLearn.java | 27 ++-- .../gameserver/model/actor/instance/Pet.java | 2 +- .../gameserver/model/actor/instance/Trap.java | 6 +- .../model/actor/tasks/player/PetFeedTask.java | 5 +- .../ConditionPlayerInsideZoneId.java | 6 +- .../conditions/ConditionPlayerInstanceId.java | 6 +- .../model/conditions/ConditionPlayerRace.java | 9 +- .../ConditionPlayerRangeFromNpc.java | 11 +- .../ConditionPlayerRangeFromSummonedNpc.java | 11 +- .../ConditionTargetClassIdRestriction.java | 6 +- .../conditions/ConditionTargetNpcId.java | 6 +- .../model/holders/EventDropHolder.java | 8 +- .../item/appearance/AppearanceStone.java | 55 ++++---- .../item/enchant/AbstractEnchantItem.java | 49 +++---- .../gameserver/model/item/henna/Henna.java | 12 +- .../model/options/OptionDataCategory.java | 8 +- .../gameserver/model/quest/LongTimeEvent.java | 4 +- .../gameserver/model/residences/ClanHall.java | 32 +++-- .../gameserver/model/siege/Castle.java | 6 +- .../serverpackets/BlockListPacket.java | 12 +- .../serverpackets/ExAcquireSkillInfo.java | 3 +- .../appearance/ExChooseShapeShiftingItem.java | 2 +- .../gameserver/util/DocumentBase.java | 37 ++--- 839 files changed, 6926 insertions(+), 5782 deletions(-) diff --git a/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/handlers/bypasshandlers/Link.java b/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/handlers/bypasshandlers/Link.java index 493e43e6f8..a275d6aa92 100644 --- a/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/handlers/bypasshandlers/Link.java +++ b/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/handlers/bypasshandlers/Link.java @@ -16,7 +16,9 @@ */ package handlers.bypasshandlers; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.HashSet; +import java.util.Set; + import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.handler.IBypassHandler; import org.l2jmobius.gameserver.model.actor.Creature; @@ -31,47 +33,48 @@ public class Link implements IBypassHandler "Link" }; - private static final String[] VALID_LINKS = + private static final Set VALID_LINKS = new HashSet<>(); + static { - "common/attribute_info.htm", - "common/augmentation_01.htm", - "common/augmentation_02.htm", - "common/crafting_01.htm", - "common/crafting_02.htm", - "common/crafting_03.htm", - "common/cursed_to_unidentified.htm", - "common/duals_01.htm", - "common/duals_02.htm", - "common/duals_03.htm", - "common/g_cube_warehouse001.htm", - "common/skill_enchant_help.htm", - "common/skill_enchant_help_01.htm", - "common/skill_enchant_help_02.htm", - "common/skill_enchant_help_03.htm", - "common/weapon_sa_01.htm", - "common/welcomeback002.htm", - "common/welcomeback003.htm", - "default/BlessingOfProtection.htm", - "default/SupportMagic.htm", - "default/SupportMagicServitor.htm", - "fisherman/exchange_old_items.htm", - "fisherman/fishing_manual001.htm", - "fisherman/fishing_manual002.htm", - "fisherman/fishing_manual003.htm", - "fisherman/fishing_manual004.htm", - "fisherman/fishing_manual008.htm", - "fisherman/fishing_manual009.htm", - "fisherman/fishing_manual010.htm", - "fortress/foreman.htm", - "guard/kamaloka_help.htm", - "guard/kamaloka_level.htm", - "petmanager/evolve.htm", - "petmanager/exchange.htm", - "petmanager/instructions.htm", - "teleporter/separatedsoul.htm", - "warehouse/clanwh.htm", - "warehouse/privatewh.htm", - }; + VALID_LINKS.add("common/attribute_info.htm"); + VALID_LINKS.add("common/augmentation_01.htm"); + VALID_LINKS.add("common/augmentation_02.htm"); + VALID_LINKS.add("common/crafting_01.htm"); + VALID_LINKS.add("common/crafting_02.htm"); + VALID_LINKS.add("common/crafting_03.htm"); + VALID_LINKS.add("common/cursed_to_unidentified.htm"); + VALID_LINKS.add("common/duals_01.htm"); + VALID_LINKS.add("common/duals_02.htm"); + VALID_LINKS.add("common/duals_03.htm"); + VALID_LINKS.add("common/g_cube_warehouse001.htm"); + VALID_LINKS.add("common/skill_enchant_help.htm"); + VALID_LINKS.add("common/skill_enchant_help_01.htm"); + VALID_LINKS.add("common/skill_enchant_help_02.htm"); + VALID_LINKS.add("common/skill_enchant_help_03.htm"); + VALID_LINKS.add("common/weapon_sa_01.htm"); + VALID_LINKS.add("common/welcomeback002.htm"); + VALID_LINKS.add("common/welcomeback003.htm"); + VALID_LINKS.add("default/BlessingOfProtection.htm"); + VALID_LINKS.add("default/SupportMagic.htm"); + VALID_LINKS.add("default/SupportMagicServitor.htm"); + VALID_LINKS.add("fisherman/exchange_old_items.htm"); + VALID_LINKS.add("fisherman/fishing_manual001.htm"); + VALID_LINKS.add("fisherman/fishing_manual002.htm"); + VALID_LINKS.add("fisherman/fishing_manual003.htm"); + VALID_LINKS.add("fisherman/fishing_manual004.htm"); + VALID_LINKS.add("fisherman/fishing_manual008.htm"); + VALID_LINKS.add("fisherman/fishing_manual009.htm"); + VALID_LINKS.add("fisherman/fishing_manual010.htm"); + VALID_LINKS.add("fortress/foreman.htm"); + VALID_LINKS.add("guard/kamaloka_help.htm"); + VALID_LINKS.add("guard/kamaloka_level.htm"); + VALID_LINKS.add("petmanager/evolve.htm"); + VALID_LINKS.add("petmanager/exchange.htm"); + VALID_LINKS.add("petmanager/instructions.htm"); + VALID_LINKS.add("teleporter/separatedsoul.htm"); + VALID_LINKS.add("warehouse/clanwh.htm"); + VALID_LINKS.add("warehouse/privatewh.htm"); + } @Override public boolean useBypass(String command, Player player, Creature target) @@ -89,12 +92,13 @@ public class Link implements IBypassHandler return false; } - String content = CommonUtil.contains(VALID_LINKS, htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; + String content = VALID_LINKS.contains(htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; // Precaution. if (htmlPath.startsWith("teleporter/") && !(player.getTarget() instanceof Teleporter)) { content = null; } + final NpcHtmlMessage html = new NpcHtmlMessage(target != null ? target.getObjectId() : 0); if (content != null) { diff --git a/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/handlers/itemhandlers/PetFood.java b/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/handlers/itemhandlers/PetFood.java index 3c5572d4ec..8b908ea095 100644 --- a/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/handlers/itemhandlers/PetFood.java +++ b/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/handlers/itemhandlers/PetFood.java @@ -17,6 +17,7 @@ package handlers.itemhandlers; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.PetDataTable; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -79,7 +80,7 @@ public class PetFood implements IItemHandler final Player player = activeChar.getActingPlayer(); if (player.isMounted()) { - final List foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); + final Set foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); if (foodIds.contains(item.getId()) && player.destroyItem("Consume", item.getObjectId(), 1, null, false)) { player.broadcastPacket(new MagicSkillUse(player, player, skillId, skillLevel, 0, 0)); diff --git a/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java b/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java index 2ad282f683..99f45fbb41 100644 --- a/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java +++ b/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.ClanHallData; import org.l2jmobius.gameserver.model.StatSet; @@ -32,12 +33,12 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpCheckResidenceSkillCondition implements ISkillCondition { - private final List _residencesId; + private final Set _residencesId = new HashSet<>(); private final boolean _isWithin; public OpCheckResidenceSkillCondition(StatSet params) { - _residencesId = params.getList("residencesId", Integer.class); + _residencesId.addAll(params.getList("residencesId", Integer.class)); _isWithin = params.getBoolean("isWithin"); } diff --git a/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java b/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java index fc2934423b..4a8282d988 100644 --- a/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java +++ b/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java @@ -16,9 +16,9 @@ */ package handlers.skillconditionhandlers; -import java.util.ArrayList; -import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -28,18 +28,18 @@ import org.l2jmobius.gameserver.model.skill.ISkillCondition; import org.l2jmobius.gameserver.model.skill.Skill; /** - * @author UnAfraid + * @author UnAfraid, Mobius */ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition { - private final List _npcIds = new ArrayList<>(); + private final Set _npcIds = new HashSet<>(); public OpNeedSummonOrPetSkillCondition(StatSet params) { - final List npcIds = params.getList("npcIds", String.class); + final List npcIds = params.getList("npcIds", Integer.class); if (npcIds != null) { - npcIds.stream().map(Integer::valueOf).forEach(_npcIds::add); + _npcIds.addAll(npcIds); } } @@ -47,7 +47,19 @@ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition public boolean canUse(Creature caster, Skill skill, WorldObject target) { final Summon pet = caster.getPet(); - final Collection summons = caster.getServitors().values(); - return ((pet != null) && _npcIds.stream().anyMatch(npcId -> npcId == pet.getId())) || summons.stream().anyMatch(summon -> _npcIds.contains(summon.getId())); + if ((pet != null) && _npcIds.contains(pet.getId())) + { + return true; + } + + for (Summon summon : caster.getServitors().values()) + { + if (_npcIds.contains(summon.getId())) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java b/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java index 8541bc62b4..ef81b291d4 100644 --- a/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java +++ b/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,11 +30,11 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetDoorSkillCondition implements ISkillCondition { - private final List _doorIds; + private final Set _doorIds = new HashSet<>(); public OpTargetDoorSkillCondition(StatSet params) { - _doorIds = params.getList("doorIds", Integer.class); + _doorIds.addAll(params.getList("doorIds", Integer.class)); } @Override diff --git a/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java b/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java index 3ce4145703..0ccd571e19 100644 --- a/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java +++ b/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,17 +30,17 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetNpcSkillCondition implements ISkillCondition { - private final List _npcId; + private final Set _npcIds = new HashSet<>(); public OpTargetNpcSkillCondition(StatSet params) { - _npcId = params.getList("npcIds", Integer.class); + _npcIds.addAll(params.getList("npcIds", Integer.class)); } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget(); - return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId()); + return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcIds.contains(actualTarget.getId()); } } diff --git a/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/instances/AbstractInstance.java b/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/instances/AbstractInstance.java index 94c337f0df..a5b4ef238a 100644 --- a/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/instances/AbstractInstance.java +++ b/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/instances/AbstractInstance.java @@ -16,9 +16,10 @@ */ package instances; +import java.util.HashSet; import java.util.List; +import java.util.Set; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.enums.InstanceReenterType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.instancemanager.InstanceManager; @@ -40,25 +41,29 @@ import ai.AbstractNpcAI; */ public abstract class AbstractInstance extends AbstractNpcAI { - private final int[] _templateIds; + private final Set _templateIds = new HashSet<>(); - public AbstractInstance(int... templateId) + public AbstractInstance(int... templateIds) { - if (templateId.length == 0) + if (templateIds.length == 0) { throw new IllegalStateException("No template ids were provided!"); } - _templateIds = templateId; + + for (int templateId : templateIds) + { + _templateIds.add(templateId); + } } - public int[] getTemplateId() + public Set getTemplateId() { return _templateIds; } public boolean isInInstance(Instance instance) { - return (instance != null) && CommonUtil.contains(_templateIds, instance.getTemplateId()); + return (instance != null) && _templateIds.contains(instance.getTemplateId()); } /** diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/Config.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/Config.java index 56ff642425..ce56da0f17 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/Config.java @@ -278,7 +278,7 @@ public class Config public static boolean AUTO_LOOT_SLOT_LIMIT; public static int LOOT_RAIDS_PRIVILEGE_INTERVAL; public static int LOOT_RAIDS_PRIVILEGE_CC_SIZE; - public static List AUTO_LOOT_ITEM_IDS; + public static Set AUTO_LOOT_ITEM_IDS; public static boolean ENABLE_KEYBOARD_MOVEMENT; public static int UNSTUCK_INTERVAL; public static int TELEPORT_WATCHDOG_TIMEOUT; @@ -454,7 +454,7 @@ public class Config public static boolean ALLOW_DISCARDITEM; public static int AUTODESTROY_ITEM_AFTER; public static int HERB_AUTO_DESTROY_TIME; - public static List LIST_PROTECTED_ITEMS; + public static Set LIST_PROTECTED_ITEMS; public static boolean DATABASE_CLEAN_UP; public static int CHAR_DATA_STORE_INTERVAL; public static int CLAN_VARIABLES_STORE_INTERVAL; @@ -549,7 +549,7 @@ public class Config public static boolean ALT_OLY_LOG_FIGHTS; public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS; public static boolean ALT_OLY_ANNOUNCE_GAMES; - public static List LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(); + public static Set LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(); public static int ALT_OLY_WEAPON_ENCHANT_LIMIT; public static int ALT_OLY_ARMOR_ENCHANT_LIMIT; public static int ALT_OLY_WAIT_TIME; @@ -1195,9 +1195,9 @@ public class Config public static int AUTO_CP_PERCENTAGE; public static int AUTO_HP_PERCENTAGE; public static int AUTO_MP_PERCENTAGE; - public static List AUTO_CP_ITEM_IDS; - public static List AUTO_HP_ITEM_IDS; - public static List AUTO_MP_ITEM_IDS; + public static Set AUTO_CP_ITEM_IDS; + public static Set AUTO_HP_ITEM_IDS; + public static Set AUTO_MP_ITEM_IDS; public static boolean CUSTOM_STARTING_LOC; public static int CUSTOM_STARTING_LOC_X; public static int CUSTOM_STARTING_LOC_Y; @@ -1207,7 +1207,7 @@ public class Config public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; public static int MOB_MIN_SPAWN_RANGE; public static int MOB_MAX_SPAWN_RANGE; - public static List MOBS_LIST_NOT_RANDOM; + public static Set MOBS_LIST_NOT_RANDOM; public static boolean FREE_JUMPS_FOR_ALL; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; @@ -1226,7 +1226,7 @@ public class Config public static boolean COMMUNITY_PREMIUM_SYSTEM_ENABLED; public static int COMMUNITY_PREMIUM_COIN_ID; public static int COMMUNITY_PREMIUM_PRICE_PER_DAY; - public static List COMMUNITY_AVAILABLE_BUFFS; + public static Set COMMUNITY_AVAILABLE_BUFFS; public static Map COMMUNITY_AVAILABLE_TELEPORTS; public static boolean CUSTOM_DEPOSITABLE_ENABLED; public static boolean CUSTOM_DEPOSITABLE_QUEST_ITEMS; @@ -1868,7 +1868,7 @@ public class Config LOOT_RAIDS_PRIVILEGE_INTERVAL = characterConfig.getInt("RaidLootRightsInterval", 900) * 1000; LOOT_RAIDS_PRIVILEGE_CC_SIZE = characterConfig.getInt("RaidLootRightsCCSize", 45); final String[] autoLootItemIds = characterConfig.getString("AutoLootItemIds", "0").split(","); - AUTO_LOOT_ITEM_IDS = new ArrayList<>(autoLootItemIds.length); + AUTO_LOOT_ITEM_IDS = new HashSet<>(autoLootItemIds.length); for (String item : autoLootItemIds) { Integer itm = 0; @@ -1988,7 +1988,7 @@ public class Config AUTODESTROY_ITEM_AFTER = generalConfig.getInt("AutoDestroyDroppedItemAfter", 600); HERB_AUTO_DESTROY_TIME = generalConfig.getInt("AutoDestroyHerbTime", 60) * 1000; final String[] split = generalConfig.getString("ListOfProtectedItems", "0").split(","); - LIST_PROTECTED_ITEMS = new ArrayList<>(split.length); + LIST_PROTECTED_ITEMS = new HashSet<>(split.length); for (String id : split) { LIST_PROTECTED_ITEMS.add(Integer.parseInt(id)); @@ -2387,7 +2387,7 @@ public class Config if (!olyRestrictedItems.isEmpty()) { final String[] olyRestrictedItemsSplit = olyRestrictedItems.split(","); - LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(olyRestrictedItemsSplit.length); + LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(olyRestrictedItemsSplit.length); for (String id : olyRestrictedItemsSplit) { LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id)); @@ -2532,17 +2532,17 @@ public class Config AUTO_CP_PERCENTAGE = autoPotionsConfig.getInt("AutoCpPercentage", 70); AUTO_HP_PERCENTAGE = autoPotionsConfig.getInt("AutoHpPercentage", 70); AUTO_MP_PERCENTAGE = autoPotionsConfig.getInt("AutoMpPercentage", 70); - AUTO_CP_ITEM_IDS = new ArrayList<>(); + AUTO_CP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoCpItemIds", "0").split(",")) { AUTO_CP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_HP_ITEM_IDS = new ArrayList<>(); + AUTO_HP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoHpItemIds", "0").split(",")) { AUTO_HP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_MP_ITEM_IDS = new ArrayList<>(); + AUTO_MP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoMpItemIds", "0").split(",")) { AUTO_MP_ITEM_IDS.add(Integer.parseInt(s)); @@ -3153,7 +3153,7 @@ public class Config COMMUNITY_PREMIUM_COIN_ID = communityBoardConfig.getInt("CommunityPremiumBuyCoinId", 57); COMMUNITY_PREMIUM_PRICE_PER_DAY = communityBoardConfig.getInt("CommunityPremiumPricePerDay", 1000000); final String[] allowedBuffs = communityBoardConfig.getString("CommunityAvailableBuffs", "").split(","); - COMMUNITY_AVAILABLE_BUFFS = new ArrayList<>(allowedBuffs.length); + COMMUNITY_AVAILABLE_BUFFS = new HashSet<>(allowedBuffs.length); for (String s : allowedBuffs) { COMMUNITY_AVAILABLE_BUFFS.add(Integer.parseInt(s)); @@ -3459,7 +3459,7 @@ public class Config if (ENABLE_RANDOM_MONSTER_SPAWNS) { final String[] mobsIds = randomSpawnsConfig.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); - MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + MOBS_LIST_NOT_RANDOM = new HashSet<>(mobsIds.length); for (String id : mobsIds) { MOBS_LIST_NOT_RANDOM.add(Integer.parseInt(id)); diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java index d6e0183c6f..c3977185b4 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java @@ -202,8 +202,7 @@ public class ClanHallData implements IXmlReader final Door door = DoorData.getInstance().getDoor(doorId); for (ClanHall ch : _clanHalls.values()) { - final List doors = ch.getDoors(); - if ((doors != null) && doors.contains(door)) + if (ch.getDoors().contains(door)) { return ch; } diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java index 6aa0a1fdde..fb395b9e2d 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java @@ -17,10 +17,10 @@ package org.l2jmobius.gameserver.data.xml; import java.io.File; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -42,7 +42,7 @@ public class FakePlayerData implements IXmlReader private final Map _fakePlayerInfos = new HashMap<>(); private final Map _fakePlayerNames = new HashMap<>(); private final Map _fakePlayerIds = new HashMap<>(); - private final List _talkableFakePlayerNames = new ArrayList<>(); + private final Set _talkableFakePlayerNames = new HashSet<>(); protected FakePlayerData() { diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java index d335b95954..1122d7b9ba 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java @@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -49,7 +51,7 @@ import org.l2jmobius.gameserver.util.Util; public class SellBuffsManager implements IXmlReader { private static final Logger LOGGER = Logger.getLogger(SellBuffsManager.class.getName()); - private static final List ALLOWED_BUFFS = new ArrayList<>(); + private static final Set ALLOWED_BUFFS = new HashSet<>(); private static final String HTML_FOLDER = "data/html/mods/SellBuffs/"; protected SellBuffsManager() @@ -76,11 +78,7 @@ public class SellBuffsManager implements IXmlReader { final Element elem = (Element) node.item(i); final int skillId = Integer.parseInt(elem.getAttribute("id")); - - if (!ALLOWED_BUFFS.contains(skillId)) - { - ALLOWED_BUFFS.add(skillId); - } + ALLOWED_BUFFS.add(skillId); } } diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java index b10f75ef3d..1e45a21319 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java @@ -19,8 +19,10 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; @@ -67,7 +69,7 @@ public class WalkingManager implements IXmlReader public static final byte REPEAT_TELE_FIRST = 2; public static final byte REPEAT_RANDOM = 3; - private final List _targetedNpcIds = new ArrayList<>(); + private final Set _targetedNpcIds = new HashSet<>(); private final Map _routes = new HashMap<>(); // all available routes private final Map _activeRoutes = new HashMap<>(); // each record represents NPC, moving by predefined route from _routes, and moving progress private final Map _routesToAttach = new HashMap<>(); // each record represents NPC and all available routes for it diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/BlockList.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/BlockList.java index 1af9941ed5..9ac6266e22 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/BlockList.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/BlockList.java @@ -19,9 +19,9 @@ package org.l2jmobius.gameserver.model; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -36,10 +36,11 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; public class BlockList { private static final Logger LOGGER = Logger.getLogger(BlockList.class.getName()); - private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); + + private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); private final Player _owner; - private List _blockList; + private Set _blockList; public BlockList(Player owner) { @@ -68,9 +69,9 @@ public class BlockList OFFLINE_LIST.put(_owner.getObjectId(), _blockList); } - private static List loadList(int objId) + private static Set loadList(int objId) { - final List list = new ArrayList<>(); + final Set list = new HashSet<>(); try (Connection con = DatabaseFactory.getConnection(); PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1")) { @@ -158,7 +159,7 @@ public class BlockList _owner.setMessageRefusal(value); } - private List getBlockList() + private Set getBlockList() { return _blockList; } diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/PetData.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/PetData.java index b534c21f36..231b85e85f 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/PetData.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/PetData.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; import org.l2jmobius.gameserver.model.holders.SkillHolder; @@ -40,7 +42,7 @@ public class PetData private int _minLevel = Byte.MAX_VALUE; private int _maxLevel = 0; private boolean _syncLevel = false; - private final List _food = new ArrayList<>(); + private final Set _food = new HashSet<>(); public PetData(int npcId, int itemId) { @@ -133,7 +135,7 @@ public class PetData /** * @return the pet's food list. */ - public List getFood() + public Set getFood() { return _food; } diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/SkillLearn.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/SkillLearn.java index a69d30f105..3d5704b5f2 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/SkillLearn.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/SkillLearn.java @@ -16,9 +16,8 @@ */ package org.l2jmobius.gameserver.model; -import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashSet; -import java.util.List; import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -40,12 +39,12 @@ public class SkillLearn private final int _getDualClassLevel; private final boolean _autoGet; private final long _levelUpSp; - private final List _requiredItems = new ArrayList<>(); - private final List _races = new ArrayList<>(); - private final List _preReqSkills = new ArrayList<>(); + private final Set _requiredItems = new HashSet<>(1); + private final Set _races = EnumSet.noneOf(Race.class); + private final Set _preReqSkills = new HashSet<>(1); private SocialClass _socialClass; private final boolean _residenceSkill; - private final List _residenceIds = new ArrayList<>(); + private final Set _residenceIds = new HashSet<>(1); private final boolean _learnedByNpc; private final boolean _learnedByFS; private final Set _removeSkills = new HashSet<>(1); @@ -133,9 +132,9 @@ public class SkillLearn } /** - * @return the list with the item holders required to acquire this skill. + * @return the set with the item holders required to acquire this skill. */ - public List getRequiredItems() + public Set getRequiredItems() { return _requiredItems; } @@ -150,9 +149,9 @@ public class SkillLearn } /** - * @return a list with the races that can acquire this skill. + * @return a set with the races that can acquire this skill. */ - public List getRaces() + public Set getRaces() { return _races; } @@ -167,9 +166,9 @@ public class SkillLearn } /** - * @return the list of skill holders required to acquire this skill. + * @return the set of skill holders required to acquire this skill. */ - public List getPreReqSkills() + public Set getPreReqSkills() { return _preReqSkills; } @@ -212,9 +211,9 @@ public class SkillLearn } /** - * @return a list with the Ids where this skill is available. + * @return a set with the Ids where this skill is available. */ - public List getResidenceIds() + public Set getResidenceIds() { return _residenceIds; } diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java index d80071ca22..b088c8b8c9 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java @@ -22,7 +22,6 @@ import java.sql.ResultSet; import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.List; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; @@ -153,7 +152,7 @@ public class Pet extends Summon broadcastStatusUpdate(); - final List foodIds = getPetData().getFood(); + final Set foodIds = getPetData().getFood(); if (foodIds.isEmpty()) { if (isUncontrollable()) diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java index 11efe435d8..1ed0ee81a4 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java @@ -16,8 +16,8 @@ */ package org.l2jmobius.gameserver.model.actor.instance; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import org.l2jmobius.commons.threads.ThreadPool; @@ -57,7 +57,7 @@ public class Trap extends Npc private boolean _isTriggered; private final int _lifeTime; private Player _owner; - private final List _playersWhoDetectedMe = new ArrayList<>(); + private final Set _playersWhoDetectedMe = new HashSet<>(); private final SkillHolder _skill; private int _remainingTime; // Tasks diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java index 71ef076212..3ba8c20a9b 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor.tasks.player; -import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -69,11 +69,12 @@ public class PetFeedTask implements Runnable _player.sendPacket(SystemMessageId.YOU_ARE_OUT_OF_FEED_MOUNT_STATUS_CANCELED); } - final List foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); + final Set foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); if (foodIds.isEmpty()) { return; } + Item food = null; for (int id : foodIds) { diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java index 50d2a821c3..2611b5f121 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.actor.Creature; @@ -29,9 +29,9 @@ import org.l2jmobius.gameserver.model.zone.ZoneType; */ public class ConditionPlayerInsideZoneId extends Condition { - private final List _zones; + private final Set _zones; - public ConditionPlayerInsideZoneId(List zones) + public ConditionPlayerInsideZoneId(Set zones) { _zones = zones; } diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java index c15065eca2..d644f663f5 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Player; @@ -29,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerInstanceId extends Condition { - private final List _instanceIds; + private final Set _instanceIds; /** * Instantiates a new condition player instance id. * @param instanceIds the instance ids */ - public ConditionPlayerInstanceId(List instanceIds) + public ConditionPlayerInstanceId(Set instanceIds) { _instanceIds = instanceIds; } diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java index 14d61089ed..7c375ec45e 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -28,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerRace extends Condition { - private final Race[] _races; + private final Set _races; /** * Instantiates a new condition player race. * @param races the list containing the allowed races. */ - public ConditionPlayerRace(Race[] races) + public ConditionPlayerRace(Set races) { _races = races; } @@ -46,6 +47,6 @@ public class ConditionPlayerRace extends Condition { return false; } - return CommonUtil.contains(_races, effector.getActingPlayer().getRace()); + return _races.contains(effector.getActingPlayer().getRace()); } } diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java index 0f54766571..0b326e3f40 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId())) + if (_npcIds.contains(target.getId())) { existNpc = true; break; diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java index c5c9b5ff0e..db64b6bd7b 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromSummonedNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromSummonedNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromSummonedNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromSummonedNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId()) && (effector == target.getSummoner())) + if (_npcIds.contains(target.getId()) && (effector == target.getSummoner())) { existNpc = true; break; diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java index a3fb0f5374..a47b4b4983 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetClassIdRestriction extends Condition { - private final List _classIds; + private final Set _classIds; /** * Instantiates a new condition target class id restriction. * @param classId the class id */ - public ConditionTargetClassIdRestriction(List classId) + public ConditionTargetClassIdRestriction(Set classId) { _classIds = classId; } diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java index 82b1bd5877..9bb694f4ef 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetNpcId extends Condition { - private final List _npcIds; + private final Set _npcIds; /** * Instantiates a new condition target npc id. * @param npcIds the npc ids */ - public ConditionTargetNpcId(List npcIds) + public ConditionTargetNpcId(Set npcIds) { _npcIds = npcIds; } diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java index f26329bc21..5c86f26ae5 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.holders; -import java.util.Collection; +import java.util.Set; /** * @author Mobius @@ -25,9 +25,9 @@ public class EventDropHolder extends DropHolder { private final int _minLevel; private final int _maxLevel; - private final Collection _monsterIds; + private final Set _monsterIds; - public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Collection monsterIds) + public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Set monsterIds) { super(null, itemId, min, max, chance); _minLevel = minLevel; @@ -45,7 +45,7 @@ public class EventDropHolder extends DropHolder return _maxLevel; } - public Collection getMonsterIds() + public Set getMonsterIds() { return _monsterIds; } diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/item/Henna.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/item/Henna.java index af805ac1bc..6c2c9feea3 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/item/Henna.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/item/Henna.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model.item; import java.util.ArrayList; import java.util.EnumMap; +import java.util.EnumSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.enums.ClassId; import org.l2jmobius.gameserver.model.StatSet; @@ -42,7 +44,7 @@ public class Henna private final int _cancelCount; private final int _duration; private final List _skills; - private final List _wearClass; + private final Set _wearClass; public Henna(StatSet set) { @@ -63,7 +65,7 @@ public class Henna _cancelCount = set.getInt("cancel_count"); _duration = set.getInt("duration", -1); _skills = new ArrayList<>(); - _wearClass = new ArrayList<>(); + _wearClass = EnumSet.noneOf(ClassId.class); } /** @@ -159,7 +161,7 @@ public class Henna /** * @return the list with the allowed classes to wear this dye. */ - public List getAllowedWearClass() + public Set getAllowedWearClass() { return _wearClass; } diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java index 18d7b61ca2..65402c4c89 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java @@ -17,9 +17,10 @@ package org.l2jmobius.gameserver.model.item.appearance; import java.time.Duration; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.enums.Race; @@ -47,12 +48,12 @@ public class AppearanceStone private final ArmorType _armorType; private final AppearanceHandType _handType; private final AppearanceMagicType _magicType; - private List _crystalTypes; - private List _targetTypes; - private List _bodyParts; - private List _races; - private List _racesNot; - private List _allVisualIds; + private Set _crystalTypes; + private Set _targetTypes; + private Set _bodyParts; + private Set _races; + private Set _racesNot; + private Set _allVisualIds; public AppearanceStone(StatSet set) { @@ -172,35 +173,35 @@ public class AppearanceStone { if (_crystalTypes == null) { - _crystalTypes = new ArrayList<>(); + _crystalTypes = EnumSet.noneOf(CrystalType.class); } _crystalTypes.add(type); } - public List getCrystalTypes() + public Set getCrystalTypes() { - return _crystalTypes != null ? _crystalTypes : Collections.emptyList(); + return _crystalTypes != null ? _crystalTypes : Collections.emptySet(); } public void addTargetType(AppearanceTargetType type) { if (_targetTypes == null) { - _targetTypes = new ArrayList<>(); + _targetTypes = EnumSet.noneOf(AppearanceTargetType.class); } _targetTypes.add(type); } - public List getTargetTypes() + public Set getTargetTypes() { - return _targetTypes != null ? _targetTypes : Collections.emptyList(); + return _targetTypes != null ? _targetTypes : Collections.emptySet(); } public void addBodyPart(Integer part) { if (_bodyParts == null) { - _bodyParts = new ArrayList<>(); + _bodyParts = new HashSet<>(); } _bodyParts.add(part); } @@ -209,47 +210,47 @@ public class AppearanceStone { if (_allVisualIds == null) { - _allVisualIds = new ArrayList<>(); + _allVisualIds = new HashSet<>(); } _allVisualIds.add(appearanceHolder); } - public List getVisualIds() + public Set getVisualIds() { - return _allVisualIds != null ? _allVisualIds : Collections.emptyList(); + return _allVisualIds != null ? _allVisualIds : Collections.emptySet(); } - public List getBodyParts() + public Set getBodyParts() { - return _bodyParts != null ? _bodyParts : Collections.emptyList(); + return _bodyParts != null ? _bodyParts : Collections.emptySet(); } public void addRace(Race race) { if (_races == null) { - _races = new ArrayList<>(); + _races = EnumSet.noneOf(Race.class); } _races.add(race); } - public List getRaces() + public Set getRaces() { - return _races != null ? _races : Collections.emptyList(); + return _races != null ? _races : Collections.emptySet(); } public void addRaceNot(Race race) { if (_racesNot == null) { - _racesNot = new ArrayList<>(); + _racesNot = EnumSet.noneOf(Race.class); } _racesNot.add(race); } - public List getRacesNot() + public Set getRacesNot() { - return _racesNot != null ? _racesNot : Collections.emptyList(); + return _racesNot != null ? _racesNot : Collections.emptySet(); } /** @@ -302,7 +303,7 @@ public class AppearanceStone { // Seems like in retail item with already changed appearance, can be changed again without being restored. - final AppearanceTargetType targetType = getTargetTypes().get(0); + final AppearanceTargetType targetType = getTargetTypes().stream().findFirst().get(); switch (targetType) { case NONE: diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java index 5d3a79d524..5e067a67e5 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java @@ -16,16 +16,16 @@ */ package org.l2jmobius.gameserver.model.item.enchant; +import java.util.EnumSet; +import java.util.Set; import java.util.logging.Logger; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.item.ItemTemplate; import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.model.item.type.CrystalType; import org.l2jmobius.gameserver.model.item.type.EtcItemType; -import org.l2jmobius.gameserver.model.item.type.ItemType; /** * @author UnAfraid @@ -34,26 +34,27 @@ public abstract class AbstractEnchantItem { protected static final Logger LOGGER = Logger.getLogger(AbstractEnchantItem.class.getName()); - private static final ItemType[] ENCHANT_TYPES = new ItemType[] + private static final Set ENCHANT_TYPES = EnumSet.noneOf(EtcItemType.class); + static { - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM, - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP, - EtcItemType.BLESS_ENCHT_AM, - EtcItemType.BLESS_ENCHT_AM_DOWN, - EtcItemType.BLESS_ENCHT_WP, - EtcItemType.ENCHT_AM, - EtcItemType.ENCHT_WP, - EtcItemType.GIANT_ENCHT_AM, - EtcItemType.GIANT_ENCHT_WP, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - }; + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + } private final int _id; private final CrystalType _grade; @@ -71,7 +72,7 @@ public abstract class AbstractEnchantItem { throw new NullPointerException(); } - else if (!CommonUtil.contains(ENCHANT_TYPES, getItem().getItemType())) + else if (!ENCHANT_TYPES.contains(getItem().getItemType())) { throw new IllegalAccessError(); } diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java index 5ba6755084..18508d0145 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java @@ -24,8 +24,10 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Set; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -184,7 +186,7 @@ public class LongTimeEvent extends Quest final Node maxLevelNode = d.getAttributes().getNamedItem("maxLevel"); final int maxLevel = maxLevelNode == null ? Integer.MAX_VALUE : Integer.parseInt(maxLevelNode.getNodeValue()); final Node monsterIdsNode = d.getAttributes().getNamedItem("monsterIds"); - final List monsterIds = new ArrayList<>(); + final Set monsterIds = new HashSet<>(); if (monsterIdsNode != null) { for (String id : monsterIdsNode.getNodeValue().split(",")) diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/residences/ClanHall.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/residences/ClanHall.java index 0c0a529077..fcc850371b 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/residences/ClanHall.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/residences/ClanHall.java @@ -23,7 +23,9 @@ import java.sql.SQLException; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -61,9 +63,9 @@ public class ClanHall extends AbstractResidence private final int _minBid; final int _lease; private final int _deposit; - private final List _npcs; - private final List _doors; - private final List _teleports; + private final Set _npcs = new HashSet<>(); + private final Set _doors = new HashSet<>(); + private final Set _teleports = new HashSet<>(); private final Location _ownerLocation; private final Location _banishLocation; // Dynamic parameters @@ -85,9 +87,21 @@ public class ClanHall extends AbstractResidence _minBid = params.getInt("minBid"); _lease = params.getInt("lease"); _deposit = params.getInt("deposit"); - _npcs = params.getList("npcList", Integer.class); - _doors = params.getList("doorList", Door.class); - _teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + final List npcs = params.getList("npcList", Integer.class); + if (npcs != null) + { + _npcs.addAll(npcs); + } + final List doors = params.getList("doorList", Door.class); + if (doors != null) + { + _doors.addAll(doors); + } + final List teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + if (teleports != null) + { + _teleports.addAll(teleports); + } _ownerLocation = params.getLocation("owner_loc"); _banishLocation = params.getLocation("banish_loc"); // Set dynamic parameters (from DB) @@ -196,7 +210,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Door} related to this {@link ClanHall}. * @return all {@link Door} related to this {@link ClanHall} */ - public List getDoors() + public Set getDoors() { return _doors; } @@ -205,7 +219,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Npc} related to this {@link ClanHall}. * @return all {@link Npc} related to this {@link ClanHall} */ - public List getNpcs() + public Set getNpcs() { return _npcs; } @@ -324,7 +338,7 @@ public class ClanHall extends AbstractResidence return _banishLocation; } - public List getTeleportList() + public Set getTeleportList() { return _teleports; } diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/siege/Castle.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/siege/Castle.java index 9f883b28a1..30a0c5b33b 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/siege/Castle.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/siege/Castle.java @@ -21,8 +21,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.Calendar; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -82,7 +84,7 @@ public class Castle extends AbstractResidence private SiegeZone _zone = null; private ResidenceTeleportZone _teleZone; private Clan _formerOwner = null; - private final List _artefacts = new ArrayList<>(1); + private final Set _artefacts = new HashSet<>(1); private final Map _function = new ConcurrentHashMap<>(); private int _ticketBuyCount = 0; private boolean _isFirstMidVictory = false; @@ -1071,7 +1073,7 @@ public class Castle extends AbstractResidence _artefacts.add(artefact); } - public List getArtefacts() + public Set getArtefacts() { return _artefacts; } diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java index 0c79677eae..4ebf954ee5 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.network.serverpackets; -import java.util.List; +import java.util.Set; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.gameserver.data.sql.CharNameTable; @@ -27,19 +27,19 @@ import org.l2jmobius.gameserver.network.OutgoingPackets; */ public class BlockListPacket implements IClientOutgoingPacket { - private final List _playersId; + private final Set _playerIds; - public BlockListPacket(List playersId) + public BlockListPacket(Set playerIds) { - _playersId = playersId; + _playerIds = playerIds; } @Override public boolean write(PacketWriter packet) { OutgoingPackets.BLOCK_LIST.writeId(packet); - packet.writeD(_playersId.size()); - for (int playerId : _playersId) + packet.writeD(_playerIds.size()); + for (int playerId : _playerIds) { packet.writeS(CharNameTable.getInstance().getNameById(playerId)); packet.writeS(""); // memo ? diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java index 8555bb6e86..eb5bfd05d8 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.network.serverpackets; import java.util.List; import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; import org.l2jmobius.commons.network.PacketWriter; @@ -37,7 +38,7 @@ public class ExAcquireSkillInfo implements IClientOutgoingPacket private final int _dualClassLevel; private final long _spCost; private final int _minLevel; - private final List _itemReq; + private final Set _itemReq; private final List _skillRem; /** diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java index 84b5fead76..a163a85735 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java @@ -35,7 +35,7 @@ public class ExChooseShapeShiftingItem implements IClientOutgoingPacket public ExChooseShapeShiftingItem(AppearanceStone stone) { _type = stone.getType(); - _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().get(0); + _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().stream().findFirst().get(); _itemId = stone.getId(); } diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/util/DocumentBase.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/util/DocumentBase.java index 8a8e13d940..c22140b9c4 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/util/DocumentBase.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/util/DocumentBase.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.util; import java.io.File; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -390,12 +391,12 @@ public abstract class DocumentBase case "races": { final String[] racesVal = a.getNodeValue().split(","); - final Race[] races = new Race[racesVal.length]; + final Set races = EnumSet.noneOf(Race.class); for (int r = 0; r < racesVal.length; r++) { if (racesVal[r] != null) { - races[r] = Race.valueOf(racesVal[r]); + races.add(Race.valueOf(racesVal[r])); } } cond = joinAnd(cond, new ConditionPlayerRace(races)); @@ -671,13 +672,13 @@ public abstract class DocumentBase case "instanceid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final ArrayList array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInstanceId(array)); + cond = joinAnd(cond, new ConditionPlayerInstanceId(set)); break; } case "agathionid": @@ -728,10 +729,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -745,10 +746,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -834,13 +835,13 @@ public abstract class DocumentBase case "insidezoneid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInsideZoneId(array)); + cond = joinAnd(cond, new ConditionPlayerInsideZoneId(set)); break; } case "checkabnormal": @@ -961,13 +962,13 @@ public abstract class DocumentBase case "class_id_restriction": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetClassIdRestriction(array)); + cond = joinAnd(cond, new ConditionTargetClassIdRestriction(set)); break; } case "active_effect_id": @@ -1045,13 +1046,13 @@ public abstract class DocumentBase case "npcid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetNpcId(array)); + cond = joinAnd(cond, new ConditionTargetNpcId(set)); break; } case "npctype": diff --git a/L2J_Mobius_02.5_Underground/dist/game/data/scripts/handlers/bypasshandlers/Link.java b/L2J_Mobius_02.5_Underground/dist/game/data/scripts/handlers/bypasshandlers/Link.java index 2fdb263f0d..988a6c499f 100644 --- a/L2J_Mobius_02.5_Underground/dist/game/data/scripts/handlers/bypasshandlers/Link.java +++ b/L2J_Mobius_02.5_Underground/dist/game/data/scripts/handlers/bypasshandlers/Link.java @@ -16,7 +16,9 @@ */ package handlers.bypasshandlers; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.HashSet; +import java.util.Set; + import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.handler.IBypassHandler; import org.l2jmobius.gameserver.model.actor.Creature; @@ -31,50 +33,51 @@ public class Link implements IBypassHandler "Link" }; - private static final String[] VALID_LINKS = + private static final Set VALID_LINKS = new HashSet<>(); + static { - "common/attribute_info.htm", - "common/augmentation_01.htm", - "common/augmentation_02.htm", - "common/augmentation_exchange.htm", - "common/crafting_01.htm", - "common/crafting_02.htm", - "common/crafting_03.htm", - "common/cursed_to_unidentified.htm", - "common/duals_01.htm", - "common/duals_02.htm", - "common/duals_03.htm", - "common/g_cube_warehouse001.htm", - "common/skill_enchant_help.htm", - "common/skill_enchant_help_01.htm", - "common/skill_enchant_help_02.htm", - "common/skill_enchant_help_03.htm", - "common/smelting_trade001.htm", - "common/weapon_sa_01.htm", - "common/welcomeback002.htm", - "common/welcomeback003.htm", - "default/BlessingOfProtection.htm", - "default/SupportMagic.htm", - "default/SupportMagicServitor.htm", - "fisherman/exchange_old_items.htm", - "fisherman/fish_appearance_exchange.htm", - "fisherman/fishing_manual001.htm", - "fisherman/fishing_manual002.htm", - "fisherman/fishing_manual003.htm", - "fisherman/fishing_manual004.htm", - "fisherman/fishing_manual008.htm", - "fisherman/fishing_manual009.htm", - "fisherman/fishing_manual010.htm", - "fortress/foreman.htm", - "guard/kamaloka_help.htm", - "guard/kamaloka_level.htm", - "petmanager/evolve.htm", - "petmanager/exchange.htm", - "petmanager/instructions.htm", - "teleporter/separatedsoul.htm", - "warehouse/clanwh.htm", - "warehouse/privatewh.htm", - }; + VALID_LINKS.add("common/attribute_info.htm"); + VALID_LINKS.add("common/augmentation_01.htm"); + VALID_LINKS.add("common/augmentation_02.htm"); + VALID_LINKS.add("common/augmentation_exchange.htm"); + VALID_LINKS.add("common/crafting_01.htm"); + VALID_LINKS.add("common/crafting_02.htm"); + VALID_LINKS.add("common/crafting_03.htm"); + VALID_LINKS.add("common/cursed_to_unidentified.htm"); + VALID_LINKS.add("common/duals_01.htm"); + VALID_LINKS.add("common/duals_02.htm"); + VALID_LINKS.add("common/duals_03.htm"); + VALID_LINKS.add("common/g_cube_warehouse001.htm"); + VALID_LINKS.add("common/skill_enchant_help.htm"); + VALID_LINKS.add("common/skill_enchant_help_01.htm"); + VALID_LINKS.add("common/skill_enchant_help_02.htm"); + VALID_LINKS.add("common/skill_enchant_help_03.htm"); + VALID_LINKS.add("common/smelting_trade001.htm"); + VALID_LINKS.add("common/weapon_sa_01.htm"); + VALID_LINKS.add("common/welcomeback002.htm"); + VALID_LINKS.add("common/welcomeback003.htm"); + VALID_LINKS.add("default/BlessingOfProtection.htm"); + VALID_LINKS.add("default/SupportMagic.htm"); + VALID_LINKS.add("default/SupportMagicServitor.htm"); + VALID_LINKS.add("fisherman/exchange_old_items.htm"); + VALID_LINKS.add("fisherman/fish_appearance_exchange.htm"); + VALID_LINKS.add("fisherman/fishing_manual001.htm"); + VALID_LINKS.add("fisherman/fishing_manual002.htm"); + VALID_LINKS.add("fisherman/fishing_manual003.htm"); + VALID_LINKS.add("fisherman/fishing_manual004.htm"); + VALID_LINKS.add("fisherman/fishing_manual008.htm"); + VALID_LINKS.add("fisherman/fishing_manual009.htm"); + VALID_LINKS.add("fisherman/fishing_manual010.htm"); + VALID_LINKS.add("fortress/foreman.htm"); + VALID_LINKS.add("guard/kamaloka_help.htm"); + VALID_LINKS.add("guard/kamaloka_level.htm"); + VALID_LINKS.add("petmanager/evolve.htm"); + VALID_LINKS.add("petmanager/exchange.htm"); + VALID_LINKS.add("petmanager/instructions.htm"); + VALID_LINKS.add("teleporter/separatedsoul.htm"); + VALID_LINKS.add("warehouse/clanwh.htm"); + VALID_LINKS.add("warehouse/privatewh.htm"); + } @Override public boolean useBypass(String command, Player player, Creature target) @@ -92,12 +95,13 @@ public class Link implements IBypassHandler return false; } - String content = CommonUtil.contains(VALID_LINKS, htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; + String content = VALID_LINKS.contains(htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; // Precaution. if (htmlPath.startsWith("teleporter/") && !(player.getTarget() instanceof Teleporter)) { content = null; } + final NpcHtmlMessage html = new NpcHtmlMessage(target != null ? target.getObjectId() : 0); if (content != null) { diff --git a/L2J_Mobius_02.5_Underground/dist/game/data/scripts/handlers/itemhandlers/PetFood.java b/L2J_Mobius_02.5_Underground/dist/game/data/scripts/handlers/itemhandlers/PetFood.java index 3c5572d4ec..8b908ea095 100644 --- a/L2J_Mobius_02.5_Underground/dist/game/data/scripts/handlers/itemhandlers/PetFood.java +++ b/L2J_Mobius_02.5_Underground/dist/game/data/scripts/handlers/itemhandlers/PetFood.java @@ -17,6 +17,7 @@ package handlers.itemhandlers; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.PetDataTable; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -79,7 +80,7 @@ public class PetFood implements IItemHandler final Player player = activeChar.getActingPlayer(); if (player.isMounted()) { - final List foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); + final Set foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); if (foodIds.contains(item.getId()) && player.destroyItem("Consume", item.getObjectId(), 1, null, false)) { player.broadcastPacket(new MagicSkillUse(player, player, skillId, skillLevel, 0, 0)); diff --git a/L2J_Mobius_02.5_Underground/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java b/L2J_Mobius_02.5_Underground/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java index 2ad282f683..99f45fbb41 100644 --- a/L2J_Mobius_02.5_Underground/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java +++ b/L2J_Mobius_02.5_Underground/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.ClanHallData; import org.l2jmobius.gameserver.model.StatSet; @@ -32,12 +33,12 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpCheckResidenceSkillCondition implements ISkillCondition { - private final List _residencesId; + private final Set _residencesId = new HashSet<>(); private final boolean _isWithin; public OpCheckResidenceSkillCondition(StatSet params) { - _residencesId = params.getList("residencesId", Integer.class); + _residencesId.addAll(params.getList("residencesId", Integer.class)); _isWithin = params.getBoolean("isWithin"); } diff --git a/L2J_Mobius_02.5_Underground/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java b/L2J_Mobius_02.5_Underground/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java index fc2934423b..4a8282d988 100644 --- a/L2J_Mobius_02.5_Underground/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java +++ b/L2J_Mobius_02.5_Underground/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java @@ -16,9 +16,9 @@ */ package handlers.skillconditionhandlers; -import java.util.ArrayList; -import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -28,18 +28,18 @@ import org.l2jmobius.gameserver.model.skill.ISkillCondition; import org.l2jmobius.gameserver.model.skill.Skill; /** - * @author UnAfraid + * @author UnAfraid, Mobius */ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition { - private final List _npcIds = new ArrayList<>(); + private final Set _npcIds = new HashSet<>(); public OpNeedSummonOrPetSkillCondition(StatSet params) { - final List npcIds = params.getList("npcIds", String.class); + final List npcIds = params.getList("npcIds", Integer.class); if (npcIds != null) { - npcIds.stream().map(Integer::valueOf).forEach(_npcIds::add); + _npcIds.addAll(npcIds); } } @@ -47,7 +47,19 @@ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition public boolean canUse(Creature caster, Skill skill, WorldObject target) { final Summon pet = caster.getPet(); - final Collection summons = caster.getServitors().values(); - return ((pet != null) && _npcIds.stream().anyMatch(npcId -> npcId == pet.getId())) || summons.stream().anyMatch(summon -> _npcIds.contains(summon.getId())); + if ((pet != null) && _npcIds.contains(pet.getId())) + { + return true; + } + + for (Summon summon : caster.getServitors().values()) + { + if (_npcIds.contains(summon.getId())) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_02.5_Underground/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java b/L2J_Mobius_02.5_Underground/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java index 8541bc62b4..ef81b291d4 100644 --- a/L2J_Mobius_02.5_Underground/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java +++ b/L2J_Mobius_02.5_Underground/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,11 +30,11 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetDoorSkillCondition implements ISkillCondition { - private final List _doorIds; + private final Set _doorIds = new HashSet<>(); public OpTargetDoorSkillCondition(StatSet params) { - _doorIds = params.getList("doorIds", Integer.class); + _doorIds.addAll(params.getList("doorIds", Integer.class)); } @Override diff --git a/L2J_Mobius_02.5_Underground/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java b/L2J_Mobius_02.5_Underground/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java index 3ce4145703..0ccd571e19 100644 --- a/L2J_Mobius_02.5_Underground/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java +++ b/L2J_Mobius_02.5_Underground/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,17 +30,17 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetNpcSkillCondition implements ISkillCondition { - private final List _npcId; + private final Set _npcIds = new HashSet<>(); public OpTargetNpcSkillCondition(StatSet params) { - _npcId = params.getList("npcIds", Integer.class); + _npcIds.addAll(params.getList("npcIds", Integer.class)); } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget(); - return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId()); + return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcIds.contains(actualTarget.getId()); } } diff --git a/L2J_Mobius_02.5_Underground/dist/game/data/scripts/instances/AbstractInstance.java b/L2J_Mobius_02.5_Underground/dist/game/data/scripts/instances/AbstractInstance.java index 94c337f0df..a5b4ef238a 100644 --- a/L2J_Mobius_02.5_Underground/dist/game/data/scripts/instances/AbstractInstance.java +++ b/L2J_Mobius_02.5_Underground/dist/game/data/scripts/instances/AbstractInstance.java @@ -16,9 +16,10 @@ */ package instances; +import java.util.HashSet; import java.util.List; +import java.util.Set; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.enums.InstanceReenterType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.instancemanager.InstanceManager; @@ -40,25 +41,29 @@ import ai.AbstractNpcAI; */ public abstract class AbstractInstance extends AbstractNpcAI { - private final int[] _templateIds; + private final Set _templateIds = new HashSet<>(); - public AbstractInstance(int... templateId) + public AbstractInstance(int... templateIds) { - if (templateId.length == 0) + if (templateIds.length == 0) { throw new IllegalStateException("No template ids were provided!"); } - _templateIds = templateId; + + for (int templateId : templateIds) + { + _templateIds.add(templateId); + } } - public int[] getTemplateId() + public Set getTemplateId() { return _templateIds; } public boolean isInInstance(Instance instance) { - return (instance != null) && CommonUtil.contains(_templateIds, instance.getTemplateId()); + return (instance != null) && _templateIds.contains(instance.getTemplateId()); } /** diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/Config.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/Config.java index 26fcab9ed2..332af96e61 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/Config.java @@ -285,7 +285,7 @@ public class Config public static boolean AUTO_LOOT_SLOT_LIMIT; public static int LOOT_RAIDS_PRIVILEGE_INTERVAL; public static int LOOT_RAIDS_PRIVILEGE_CC_SIZE; - public static List AUTO_LOOT_ITEM_IDS; + public static Set AUTO_LOOT_ITEM_IDS; public static boolean ENABLE_KEYBOARD_MOVEMENT; public static int UNSTUCK_INTERVAL; public static int TELEPORT_WATCHDOG_TIMEOUT; @@ -461,7 +461,7 @@ public class Config public static boolean ALLOW_DISCARDITEM; public static int AUTODESTROY_ITEM_AFTER; public static int HERB_AUTO_DESTROY_TIME; - public static List LIST_PROTECTED_ITEMS; + public static Set LIST_PROTECTED_ITEMS; public static boolean DATABASE_CLEAN_UP; public static int CHAR_DATA_STORE_INTERVAL; public static int CLAN_VARIABLES_STORE_INTERVAL; @@ -559,7 +559,7 @@ public class Config public static boolean ALT_OLY_LOG_FIGHTS; public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS; public static boolean ALT_OLY_ANNOUNCE_GAMES; - public static List LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(); + public static Set LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(); public static int ALT_OLY_WEAPON_ENCHANT_LIMIT; public static int ALT_OLY_ARMOR_ENCHANT_LIMIT; public static int ALT_OLY_WAIT_TIME; @@ -1206,9 +1206,9 @@ public class Config public static int AUTO_CP_PERCENTAGE; public static int AUTO_HP_PERCENTAGE; public static int AUTO_MP_PERCENTAGE; - public static List AUTO_CP_ITEM_IDS; - public static List AUTO_HP_ITEM_IDS; - public static List AUTO_MP_ITEM_IDS; + public static Set AUTO_CP_ITEM_IDS; + public static Set AUTO_HP_ITEM_IDS; + public static Set AUTO_MP_ITEM_IDS; public static boolean CUSTOM_STARTING_LOC; public static int CUSTOM_STARTING_LOC_X; public static int CUSTOM_STARTING_LOC_Y; @@ -1218,7 +1218,7 @@ public class Config public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; public static int MOB_MIN_SPAWN_RANGE; public static int MOB_MAX_SPAWN_RANGE; - public static List MOBS_LIST_NOT_RANDOM; + public static Set MOBS_LIST_NOT_RANDOM; public static boolean FREE_JUMPS_FOR_ALL; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; @@ -1237,7 +1237,7 @@ public class Config public static boolean COMMUNITY_PREMIUM_SYSTEM_ENABLED; public static int COMMUNITY_PREMIUM_COIN_ID; public static int COMMUNITY_PREMIUM_PRICE_PER_DAY; - public static List COMMUNITY_AVAILABLE_BUFFS; + public static Set COMMUNITY_AVAILABLE_BUFFS; public static Map COMMUNITY_AVAILABLE_TELEPORTS; public static boolean CUSTOM_DEPOSITABLE_ENABLED; public static boolean CUSTOM_DEPOSITABLE_QUEST_ITEMS; @@ -1888,7 +1888,7 @@ public class Config LOOT_RAIDS_PRIVILEGE_INTERVAL = characterConfig.getInt("RaidLootRightsInterval", 900) * 1000; LOOT_RAIDS_PRIVILEGE_CC_SIZE = characterConfig.getInt("RaidLootRightsCCSize", 45); final String[] autoLootItemIds = characterConfig.getString("AutoLootItemIds", "0").split(","); - AUTO_LOOT_ITEM_IDS = new ArrayList<>(autoLootItemIds.length); + AUTO_LOOT_ITEM_IDS = new HashSet<>(autoLootItemIds.length); for (String item : autoLootItemIds) { Integer itm = 0; @@ -2008,7 +2008,7 @@ public class Config AUTODESTROY_ITEM_AFTER = generalConfig.getInt("AutoDestroyDroppedItemAfter", 600); HERB_AUTO_DESTROY_TIME = generalConfig.getInt("AutoDestroyHerbTime", 60) * 1000; final String[] split = generalConfig.getString("ListOfProtectedItems", "0").split(","); - LIST_PROTECTED_ITEMS = new ArrayList<>(split.length); + LIST_PROTECTED_ITEMS = new HashSet<>(split.length); for (String id : split) { LIST_PROTECTED_ITEMS.add(Integer.parseInt(id)); @@ -2410,7 +2410,7 @@ public class Config if (!olyRestrictedItems.isEmpty()) { final String[] olyRestrictedItemsSplit = olyRestrictedItems.split(","); - LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(olyRestrictedItemsSplit.length); + LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(olyRestrictedItemsSplit.length); for (String id : olyRestrictedItemsSplit) { LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id)); @@ -2555,17 +2555,17 @@ public class Config AUTO_CP_PERCENTAGE = autoPotionsConfig.getInt("AutoCpPercentage", 70); AUTO_HP_PERCENTAGE = autoPotionsConfig.getInt("AutoHpPercentage", 70); AUTO_MP_PERCENTAGE = autoPotionsConfig.getInt("AutoMpPercentage", 70); - AUTO_CP_ITEM_IDS = new ArrayList<>(); + AUTO_CP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoCpItemIds", "0").split(",")) { AUTO_CP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_HP_ITEM_IDS = new ArrayList<>(); + AUTO_HP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoHpItemIds", "0").split(",")) { AUTO_HP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_MP_ITEM_IDS = new ArrayList<>(); + AUTO_MP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoMpItemIds", "0").split(",")) { AUTO_MP_ITEM_IDS.add(Integer.parseInt(s)); @@ -3176,7 +3176,7 @@ public class Config COMMUNITY_PREMIUM_COIN_ID = communityBoardConfig.getInt("CommunityPremiumBuyCoinId", 57); COMMUNITY_PREMIUM_PRICE_PER_DAY = communityBoardConfig.getInt("CommunityPremiumPricePerDay", 1000000); final String[] allowedBuffs = communityBoardConfig.getString("CommunityAvailableBuffs", "").split(","); - COMMUNITY_AVAILABLE_BUFFS = new ArrayList<>(allowedBuffs.length); + COMMUNITY_AVAILABLE_BUFFS = new HashSet<>(allowedBuffs.length); for (String s : allowedBuffs) { COMMUNITY_AVAILABLE_BUFFS.add(Integer.parseInt(s)); @@ -3483,7 +3483,7 @@ public class Config if (ENABLE_RANDOM_MONSTER_SPAWNS) { final String[] mobsIds = randomSpawnsConfig.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); - MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + MOBS_LIST_NOT_RANDOM = new HashSet<>(mobsIds.length); for (String id : mobsIds) { MOBS_LIST_NOT_RANDOM.add(Integer.parseInt(id)); diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java index d6e0183c6f..c3977185b4 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java @@ -202,8 +202,7 @@ public class ClanHallData implements IXmlReader final Door door = DoorData.getInstance().getDoor(doorId); for (ClanHall ch : _clanHalls.values()) { - final List doors = ch.getDoors(); - if ((doors != null) && doors.contains(door)) + if (ch.getDoors().contains(door)) { return ch; } diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java index 6aa0a1fdde..fb395b9e2d 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java @@ -17,10 +17,10 @@ package org.l2jmobius.gameserver.data.xml; import java.io.File; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -42,7 +42,7 @@ public class FakePlayerData implements IXmlReader private final Map _fakePlayerInfos = new HashMap<>(); private final Map _fakePlayerNames = new HashMap<>(); private final Map _fakePlayerIds = new HashMap<>(); - private final List _talkableFakePlayerNames = new ArrayList<>(); + private final Set _talkableFakePlayerNames = new HashSet<>(); protected FakePlayerData() { diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java index d335b95954..1122d7b9ba 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java @@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -49,7 +51,7 @@ import org.l2jmobius.gameserver.util.Util; public class SellBuffsManager implements IXmlReader { private static final Logger LOGGER = Logger.getLogger(SellBuffsManager.class.getName()); - private static final List ALLOWED_BUFFS = new ArrayList<>(); + private static final Set ALLOWED_BUFFS = new HashSet<>(); private static final String HTML_FOLDER = "data/html/mods/SellBuffs/"; protected SellBuffsManager() @@ -76,11 +78,7 @@ public class SellBuffsManager implements IXmlReader { final Element elem = (Element) node.item(i); final int skillId = Integer.parseInt(elem.getAttribute("id")); - - if (!ALLOWED_BUFFS.contains(skillId)) - { - ALLOWED_BUFFS.add(skillId); - } + ALLOWED_BUFFS.add(skillId); } } diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java index b10f75ef3d..1e45a21319 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java @@ -19,8 +19,10 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; @@ -67,7 +69,7 @@ public class WalkingManager implements IXmlReader public static final byte REPEAT_TELE_FIRST = 2; public static final byte REPEAT_RANDOM = 3; - private final List _targetedNpcIds = new ArrayList<>(); + private final Set _targetedNpcIds = new HashSet<>(); private final Map _routes = new HashMap<>(); // all available routes private final Map _activeRoutes = new HashMap<>(); // each record represents NPC, moving by predefined route from _routes, and moving progress private final Map _routesToAttach = new HashMap<>(); // each record represents NPC and all available routes for it diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/BlockList.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/BlockList.java index 1af9941ed5..9ac6266e22 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/BlockList.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/BlockList.java @@ -19,9 +19,9 @@ package org.l2jmobius.gameserver.model; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -36,10 +36,11 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; public class BlockList { private static final Logger LOGGER = Logger.getLogger(BlockList.class.getName()); - private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); + + private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); private final Player _owner; - private List _blockList; + private Set _blockList; public BlockList(Player owner) { @@ -68,9 +69,9 @@ public class BlockList OFFLINE_LIST.put(_owner.getObjectId(), _blockList); } - private static List loadList(int objId) + private static Set loadList(int objId) { - final List list = new ArrayList<>(); + final Set list = new HashSet<>(); try (Connection con = DatabaseFactory.getConnection(); PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1")) { @@ -158,7 +159,7 @@ public class BlockList _owner.setMessageRefusal(value); } - private List getBlockList() + private Set getBlockList() { return _blockList; } diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/PetData.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/PetData.java index b534c21f36..231b85e85f 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/PetData.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/PetData.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; import org.l2jmobius.gameserver.model.holders.SkillHolder; @@ -40,7 +42,7 @@ public class PetData private int _minLevel = Byte.MAX_VALUE; private int _maxLevel = 0; private boolean _syncLevel = false; - private final List _food = new ArrayList<>(); + private final Set _food = new HashSet<>(); public PetData(int npcId, int itemId) { @@ -133,7 +135,7 @@ public class PetData /** * @return the pet's food list. */ - public List getFood() + public Set getFood() { return _food; } diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/SkillLearn.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/SkillLearn.java index a69d30f105..3d5704b5f2 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/SkillLearn.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/SkillLearn.java @@ -16,9 +16,8 @@ */ package org.l2jmobius.gameserver.model; -import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashSet; -import java.util.List; import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -40,12 +39,12 @@ public class SkillLearn private final int _getDualClassLevel; private final boolean _autoGet; private final long _levelUpSp; - private final List _requiredItems = new ArrayList<>(); - private final List _races = new ArrayList<>(); - private final List _preReqSkills = new ArrayList<>(); + private final Set _requiredItems = new HashSet<>(1); + private final Set _races = EnumSet.noneOf(Race.class); + private final Set _preReqSkills = new HashSet<>(1); private SocialClass _socialClass; private final boolean _residenceSkill; - private final List _residenceIds = new ArrayList<>(); + private final Set _residenceIds = new HashSet<>(1); private final boolean _learnedByNpc; private final boolean _learnedByFS; private final Set _removeSkills = new HashSet<>(1); @@ -133,9 +132,9 @@ public class SkillLearn } /** - * @return the list with the item holders required to acquire this skill. + * @return the set with the item holders required to acquire this skill. */ - public List getRequiredItems() + public Set getRequiredItems() { return _requiredItems; } @@ -150,9 +149,9 @@ public class SkillLearn } /** - * @return a list with the races that can acquire this skill. + * @return a set with the races that can acquire this skill. */ - public List getRaces() + public Set getRaces() { return _races; } @@ -167,9 +166,9 @@ public class SkillLearn } /** - * @return the list of skill holders required to acquire this skill. + * @return the set of skill holders required to acquire this skill. */ - public List getPreReqSkills() + public Set getPreReqSkills() { return _preReqSkills; } @@ -212,9 +211,9 @@ public class SkillLearn } /** - * @return a list with the Ids where this skill is available. + * @return a set with the Ids where this skill is available. */ - public List getResidenceIds() + public Set getResidenceIds() { return _residenceIds; } diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java index d80071ca22..b088c8b8c9 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java @@ -22,7 +22,6 @@ import java.sql.ResultSet; import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.List; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; @@ -153,7 +152,7 @@ public class Pet extends Summon broadcastStatusUpdate(); - final List foodIds = getPetData().getFood(); + final Set foodIds = getPetData().getFood(); if (foodIds.isEmpty()) { if (isUncontrollable()) diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java index 11efe435d8..1ed0ee81a4 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java @@ -16,8 +16,8 @@ */ package org.l2jmobius.gameserver.model.actor.instance; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import org.l2jmobius.commons.threads.ThreadPool; @@ -57,7 +57,7 @@ public class Trap extends Npc private boolean _isTriggered; private final int _lifeTime; private Player _owner; - private final List _playersWhoDetectedMe = new ArrayList<>(); + private final Set _playersWhoDetectedMe = new HashSet<>(); private final SkillHolder _skill; private int _remainingTime; // Tasks diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java index 71ef076212..3ba8c20a9b 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor.tasks.player; -import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -69,11 +69,12 @@ public class PetFeedTask implements Runnable _player.sendPacket(SystemMessageId.YOU_ARE_OUT_OF_FEED_MOUNT_STATUS_CANCELED); } - final List foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); + final Set foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); if (foodIds.isEmpty()) { return; } + Item food = null; for (int id : foodIds) { diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java index 50d2a821c3..2611b5f121 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.actor.Creature; @@ -29,9 +29,9 @@ import org.l2jmobius.gameserver.model.zone.ZoneType; */ public class ConditionPlayerInsideZoneId extends Condition { - private final List _zones; + private final Set _zones; - public ConditionPlayerInsideZoneId(List zones) + public ConditionPlayerInsideZoneId(Set zones) { _zones = zones; } diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java index c15065eca2..d644f663f5 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Player; @@ -29,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerInstanceId extends Condition { - private final List _instanceIds; + private final Set _instanceIds; /** * Instantiates a new condition player instance id. * @param instanceIds the instance ids */ - public ConditionPlayerInstanceId(List instanceIds) + public ConditionPlayerInstanceId(Set instanceIds) { _instanceIds = instanceIds; } diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java index 14d61089ed..7c375ec45e 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -28,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerRace extends Condition { - private final Race[] _races; + private final Set _races; /** * Instantiates a new condition player race. * @param races the list containing the allowed races. */ - public ConditionPlayerRace(Race[] races) + public ConditionPlayerRace(Set races) { _races = races; } @@ -46,6 +47,6 @@ public class ConditionPlayerRace extends Condition { return false; } - return CommonUtil.contains(_races, effector.getActingPlayer().getRace()); + return _races.contains(effector.getActingPlayer().getRace()); } } diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java index 0f54766571..0b326e3f40 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId())) + if (_npcIds.contains(target.getId())) { existNpc = true; break; diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java index c5c9b5ff0e..db64b6bd7b 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromSummonedNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromSummonedNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromSummonedNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromSummonedNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId()) && (effector == target.getSummoner())) + if (_npcIds.contains(target.getId()) && (effector == target.getSummoner())) { existNpc = true; break; diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java index a3fb0f5374..a47b4b4983 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetClassIdRestriction extends Condition { - private final List _classIds; + private final Set _classIds; /** * Instantiates a new condition target class id restriction. * @param classId the class id */ - public ConditionTargetClassIdRestriction(List classId) + public ConditionTargetClassIdRestriction(Set classId) { _classIds = classId; } diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java index 82b1bd5877..9bb694f4ef 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetNpcId extends Condition { - private final List _npcIds; + private final Set _npcIds; /** * Instantiates a new condition target npc id. * @param npcIds the npc ids */ - public ConditionTargetNpcId(List npcIds) + public ConditionTargetNpcId(Set npcIds) { _npcIds = npcIds; } diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java index f26329bc21..5c86f26ae5 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.holders; -import java.util.Collection; +import java.util.Set; /** * @author Mobius @@ -25,9 +25,9 @@ public class EventDropHolder extends DropHolder { private final int _minLevel; private final int _maxLevel; - private final Collection _monsterIds; + private final Set _monsterIds; - public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Collection monsterIds) + public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Set monsterIds) { super(null, itemId, min, max, chance); _minLevel = minLevel; @@ -45,7 +45,7 @@ public class EventDropHolder extends DropHolder return _maxLevel; } - public Collection getMonsterIds() + public Set getMonsterIds() { return _monsterIds; } diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/item/Henna.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/item/Henna.java index af805ac1bc..6c2c9feea3 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/item/Henna.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/item/Henna.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model.item; import java.util.ArrayList; import java.util.EnumMap; +import java.util.EnumSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.enums.ClassId; import org.l2jmobius.gameserver.model.StatSet; @@ -42,7 +44,7 @@ public class Henna private final int _cancelCount; private final int _duration; private final List _skills; - private final List _wearClass; + private final Set _wearClass; public Henna(StatSet set) { @@ -63,7 +65,7 @@ public class Henna _cancelCount = set.getInt("cancel_count"); _duration = set.getInt("duration", -1); _skills = new ArrayList<>(); - _wearClass = new ArrayList<>(); + _wearClass = EnumSet.noneOf(ClassId.class); } /** @@ -159,7 +161,7 @@ public class Henna /** * @return the list with the allowed classes to wear this dye. */ - public List getAllowedWearClass() + public Set getAllowedWearClass() { return _wearClass; } diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java index 18d7b61ca2..65402c4c89 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java @@ -17,9 +17,10 @@ package org.l2jmobius.gameserver.model.item.appearance; import java.time.Duration; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.enums.Race; @@ -47,12 +48,12 @@ public class AppearanceStone private final ArmorType _armorType; private final AppearanceHandType _handType; private final AppearanceMagicType _magicType; - private List _crystalTypes; - private List _targetTypes; - private List _bodyParts; - private List _races; - private List _racesNot; - private List _allVisualIds; + private Set _crystalTypes; + private Set _targetTypes; + private Set _bodyParts; + private Set _races; + private Set _racesNot; + private Set _allVisualIds; public AppearanceStone(StatSet set) { @@ -172,35 +173,35 @@ public class AppearanceStone { if (_crystalTypes == null) { - _crystalTypes = new ArrayList<>(); + _crystalTypes = EnumSet.noneOf(CrystalType.class); } _crystalTypes.add(type); } - public List getCrystalTypes() + public Set getCrystalTypes() { - return _crystalTypes != null ? _crystalTypes : Collections.emptyList(); + return _crystalTypes != null ? _crystalTypes : Collections.emptySet(); } public void addTargetType(AppearanceTargetType type) { if (_targetTypes == null) { - _targetTypes = new ArrayList<>(); + _targetTypes = EnumSet.noneOf(AppearanceTargetType.class); } _targetTypes.add(type); } - public List getTargetTypes() + public Set getTargetTypes() { - return _targetTypes != null ? _targetTypes : Collections.emptyList(); + return _targetTypes != null ? _targetTypes : Collections.emptySet(); } public void addBodyPart(Integer part) { if (_bodyParts == null) { - _bodyParts = new ArrayList<>(); + _bodyParts = new HashSet<>(); } _bodyParts.add(part); } @@ -209,47 +210,47 @@ public class AppearanceStone { if (_allVisualIds == null) { - _allVisualIds = new ArrayList<>(); + _allVisualIds = new HashSet<>(); } _allVisualIds.add(appearanceHolder); } - public List getVisualIds() + public Set getVisualIds() { - return _allVisualIds != null ? _allVisualIds : Collections.emptyList(); + return _allVisualIds != null ? _allVisualIds : Collections.emptySet(); } - public List getBodyParts() + public Set getBodyParts() { - return _bodyParts != null ? _bodyParts : Collections.emptyList(); + return _bodyParts != null ? _bodyParts : Collections.emptySet(); } public void addRace(Race race) { if (_races == null) { - _races = new ArrayList<>(); + _races = EnumSet.noneOf(Race.class); } _races.add(race); } - public List getRaces() + public Set getRaces() { - return _races != null ? _races : Collections.emptyList(); + return _races != null ? _races : Collections.emptySet(); } public void addRaceNot(Race race) { if (_racesNot == null) { - _racesNot = new ArrayList<>(); + _racesNot = EnumSet.noneOf(Race.class); } _racesNot.add(race); } - public List getRacesNot() + public Set getRacesNot() { - return _racesNot != null ? _racesNot : Collections.emptyList(); + return _racesNot != null ? _racesNot : Collections.emptySet(); } /** @@ -302,7 +303,7 @@ public class AppearanceStone { // Seems like in retail item with already changed appearance, can be changed again without being restored. - final AppearanceTargetType targetType = getTargetTypes().get(0); + final AppearanceTargetType targetType = getTargetTypes().stream().findFirst().get(); switch (targetType) { case NONE: diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java index 5d3a79d524..5e067a67e5 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java @@ -16,16 +16,16 @@ */ package org.l2jmobius.gameserver.model.item.enchant; +import java.util.EnumSet; +import java.util.Set; import java.util.logging.Logger; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.item.ItemTemplate; import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.model.item.type.CrystalType; import org.l2jmobius.gameserver.model.item.type.EtcItemType; -import org.l2jmobius.gameserver.model.item.type.ItemType; /** * @author UnAfraid @@ -34,26 +34,27 @@ public abstract class AbstractEnchantItem { protected static final Logger LOGGER = Logger.getLogger(AbstractEnchantItem.class.getName()); - private static final ItemType[] ENCHANT_TYPES = new ItemType[] + private static final Set ENCHANT_TYPES = EnumSet.noneOf(EtcItemType.class); + static { - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM, - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP, - EtcItemType.BLESS_ENCHT_AM, - EtcItemType.BLESS_ENCHT_AM_DOWN, - EtcItemType.BLESS_ENCHT_WP, - EtcItemType.ENCHT_AM, - EtcItemType.ENCHT_WP, - EtcItemType.GIANT_ENCHT_AM, - EtcItemType.GIANT_ENCHT_WP, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - }; + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + } private final int _id; private final CrystalType _grade; @@ -71,7 +72,7 @@ public abstract class AbstractEnchantItem { throw new NullPointerException(); } - else if (!CommonUtil.contains(ENCHANT_TYPES, getItem().getItemType())) + else if (!ENCHANT_TYPES.contains(getItem().getItemType())) { throw new IllegalAccessError(); } diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java index 5ba6755084..18508d0145 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java @@ -24,8 +24,10 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Set; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -184,7 +186,7 @@ public class LongTimeEvent extends Quest final Node maxLevelNode = d.getAttributes().getNamedItem("maxLevel"); final int maxLevel = maxLevelNode == null ? Integer.MAX_VALUE : Integer.parseInt(maxLevelNode.getNodeValue()); final Node monsterIdsNode = d.getAttributes().getNamedItem("monsterIds"); - final List monsterIds = new ArrayList<>(); + final Set monsterIds = new HashSet<>(); if (monsterIdsNode != null) { for (String id : monsterIdsNode.getNodeValue().split(",")) diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/residences/ClanHall.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/residences/ClanHall.java index 0c0a529077..fcc850371b 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/residences/ClanHall.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/residences/ClanHall.java @@ -23,7 +23,9 @@ import java.sql.SQLException; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -61,9 +63,9 @@ public class ClanHall extends AbstractResidence private final int _minBid; final int _lease; private final int _deposit; - private final List _npcs; - private final List _doors; - private final List _teleports; + private final Set _npcs = new HashSet<>(); + private final Set _doors = new HashSet<>(); + private final Set _teleports = new HashSet<>(); private final Location _ownerLocation; private final Location _banishLocation; // Dynamic parameters @@ -85,9 +87,21 @@ public class ClanHall extends AbstractResidence _minBid = params.getInt("minBid"); _lease = params.getInt("lease"); _deposit = params.getInt("deposit"); - _npcs = params.getList("npcList", Integer.class); - _doors = params.getList("doorList", Door.class); - _teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + final List npcs = params.getList("npcList", Integer.class); + if (npcs != null) + { + _npcs.addAll(npcs); + } + final List doors = params.getList("doorList", Door.class); + if (doors != null) + { + _doors.addAll(doors); + } + final List teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + if (teleports != null) + { + _teleports.addAll(teleports); + } _ownerLocation = params.getLocation("owner_loc"); _banishLocation = params.getLocation("banish_loc"); // Set dynamic parameters (from DB) @@ -196,7 +210,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Door} related to this {@link ClanHall}. * @return all {@link Door} related to this {@link ClanHall} */ - public List getDoors() + public Set getDoors() { return _doors; } @@ -205,7 +219,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Npc} related to this {@link ClanHall}. * @return all {@link Npc} related to this {@link ClanHall} */ - public List getNpcs() + public Set getNpcs() { return _npcs; } @@ -324,7 +338,7 @@ public class ClanHall extends AbstractResidence return _banishLocation; } - public List getTeleportList() + public Set getTeleportList() { return _teleports; } diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/siege/Castle.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/siege/Castle.java index 9f883b28a1..30a0c5b33b 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/siege/Castle.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/siege/Castle.java @@ -21,8 +21,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.Calendar; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -82,7 +84,7 @@ public class Castle extends AbstractResidence private SiegeZone _zone = null; private ResidenceTeleportZone _teleZone; private Clan _formerOwner = null; - private final List _artefacts = new ArrayList<>(1); + private final Set _artefacts = new HashSet<>(1); private final Map _function = new ConcurrentHashMap<>(); private int _ticketBuyCount = 0; private boolean _isFirstMidVictory = false; @@ -1071,7 +1073,7 @@ public class Castle extends AbstractResidence _artefacts.add(artefact); } - public List getArtefacts() + public Set getArtefacts() { return _artefacts; } diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java index 0c79677eae..4ebf954ee5 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.network.serverpackets; -import java.util.List; +import java.util.Set; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.gameserver.data.sql.CharNameTable; @@ -27,19 +27,19 @@ import org.l2jmobius.gameserver.network.OutgoingPackets; */ public class BlockListPacket implements IClientOutgoingPacket { - private final List _playersId; + private final Set _playerIds; - public BlockListPacket(List playersId) + public BlockListPacket(Set playerIds) { - _playersId = playersId; + _playerIds = playerIds; } @Override public boolean write(PacketWriter packet) { OutgoingPackets.BLOCK_LIST.writeId(packet); - packet.writeD(_playersId.size()); - for (int playerId : _playersId) + packet.writeD(_playerIds.size()); + for (int playerId : _playerIds) { packet.writeS(CharNameTable.getInstance().getNameById(playerId)); packet.writeS(""); // memo ? diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java index 8555bb6e86..eb5bfd05d8 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.network.serverpackets; import java.util.List; import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; import org.l2jmobius.commons.network.PacketWriter; @@ -37,7 +38,7 @@ public class ExAcquireSkillInfo implements IClientOutgoingPacket private final int _dualClassLevel; private final long _spCost; private final int _minLevel; - private final List _itemReq; + private final Set _itemReq; private final List _skillRem; /** diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java index 84b5fead76..a163a85735 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java @@ -35,7 +35,7 @@ public class ExChooseShapeShiftingItem implements IClientOutgoingPacket public ExChooseShapeShiftingItem(AppearanceStone stone) { _type = stone.getType(); - _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().get(0); + _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().stream().findFirst().get(); _itemId = stone.getId(); } diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/util/DocumentBase.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/util/DocumentBase.java index 8a8e13d940..c22140b9c4 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/util/DocumentBase.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/util/DocumentBase.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.util; import java.io.File; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -390,12 +391,12 @@ public abstract class DocumentBase case "races": { final String[] racesVal = a.getNodeValue().split(","); - final Race[] races = new Race[racesVal.length]; + final Set races = EnumSet.noneOf(Race.class); for (int r = 0; r < racesVal.length; r++) { if (racesVal[r] != null) { - races[r] = Race.valueOf(racesVal[r]); + races.add(Race.valueOf(racesVal[r])); } } cond = joinAnd(cond, new ConditionPlayerRace(races)); @@ -671,13 +672,13 @@ public abstract class DocumentBase case "instanceid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final ArrayList array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInstanceId(array)); + cond = joinAnd(cond, new ConditionPlayerInstanceId(set)); break; } case "agathionid": @@ -728,10 +729,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -745,10 +746,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -834,13 +835,13 @@ public abstract class DocumentBase case "insidezoneid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInsideZoneId(array)); + cond = joinAnd(cond, new ConditionPlayerInsideZoneId(set)); break; } case "checkabnormal": @@ -961,13 +962,13 @@ public abstract class DocumentBase case "class_id_restriction": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetClassIdRestriction(array)); + cond = joinAnd(cond, new ConditionTargetClassIdRestriction(set)); break; } case "active_effect_id": @@ -1045,13 +1046,13 @@ public abstract class DocumentBase case "npcid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetNpcId(array)); + cond = joinAnd(cond, new ConditionTargetNpcId(set)); break; } case "npctype": diff --git a/L2J_Mobius_03.0_Helios/dist/game/data/scripts/handlers/bypasshandlers/Link.java b/L2J_Mobius_03.0_Helios/dist/game/data/scripts/handlers/bypasshandlers/Link.java index 2fdb263f0d..988a6c499f 100644 --- a/L2J_Mobius_03.0_Helios/dist/game/data/scripts/handlers/bypasshandlers/Link.java +++ b/L2J_Mobius_03.0_Helios/dist/game/data/scripts/handlers/bypasshandlers/Link.java @@ -16,7 +16,9 @@ */ package handlers.bypasshandlers; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.HashSet; +import java.util.Set; + import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.handler.IBypassHandler; import org.l2jmobius.gameserver.model.actor.Creature; @@ -31,50 +33,51 @@ public class Link implements IBypassHandler "Link" }; - private static final String[] VALID_LINKS = + private static final Set VALID_LINKS = new HashSet<>(); + static { - "common/attribute_info.htm", - "common/augmentation_01.htm", - "common/augmentation_02.htm", - "common/augmentation_exchange.htm", - "common/crafting_01.htm", - "common/crafting_02.htm", - "common/crafting_03.htm", - "common/cursed_to_unidentified.htm", - "common/duals_01.htm", - "common/duals_02.htm", - "common/duals_03.htm", - "common/g_cube_warehouse001.htm", - "common/skill_enchant_help.htm", - "common/skill_enchant_help_01.htm", - "common/skill_enchant_help_02.htm", - "common/skill_enchant_help_03.htm", - "common/smelting_trade001.htm", - "common/weapon_sa_01.htm", - "common/welcomeback002.htm", - "common/welcomeback003.htm", - "default/BlessingOfProtection.htm", - "default/SupportMagic.htm", - "default/SupportMagicServitor.htm", - "fisherman/exchange_old_items.htm", - "fisherman/fish_appearance_exchange.htm", - "fisherman/fishing_manual001.htm", - "fisherman/fishing_manual002.htm", - "fisherman/fishing_manual003.htm", - "fisherman/fishing_manual004.htm", - "fisherman/fishing_manual008.htm", - "fisherman/fishing_manual009.htm", - "fisherman/fishing_manual010.htm", - "fortress/foreman.htm", - "guard/kamaloka_help.htm", - "guard/kamaloka_level.htm", - "petmanager/evolve.htm", - "petmanager/exchange.htm", - "petmanager/instructions.htm", - "teleporter/separatedsoul.htm", - "warehouse/clanwh.htm", - "warehouse/privatewh.htm", - }; + VALID_LINKS.add("common/attribute_info.htm"); + VALID_LINKS.add("common/augmentation_01.htm"); + VALID_LINKS.add("common/augmentation_02.htm"); + VALID_LINKS.add("common/augmentation_exchange.htm"); + VALID_LINKS.add("common/crafting_01.htm"); + VALID_LINKS.add("common/crafting_02.htm"); + VALID_LINKS.add("common/crafting_03.htm"); + VALID_LINKS.add("common/cursed_to_unidentified.htm"); + VALID_LINKS.add("common/duals_01.htm"); + VALID_LINKS.add("common/duals_02.htm"); + VALID_LINKS.add("common/duals_03.htm"); + VALID_LINKS.add("common/g_cube_warehouse001.htm"); + VALID_LINKS.add("common/skill_enchant_help.htm"); + VALID_LINKS.add("common/skill_enchant_help_01.htm"); + VALID_LINKS.add("common/skill_enchant_help_02.htm"); + VALID_LINKS.add("common/skill_enchant_help_03.htm"); + VALID_LINKS.add("common/smelting_trade001.htm"); + VALID_LINKS.add("common/weapon_sa_01.htm"); + VALID_LINKS.add("common/welcomeback002.htm"); + VALID_LINKS.add("common/welcomeback003.htm"); + VALID_LINKS.add("default/BlessingOfProtection.htm"); + VALID_LINKS.add("default/SupportMagic.htm"); + VALID_LINKS.add("default/SupportMagicServitor.htm"); + VALID_LINKS.add("fisherman/exchange_old_items.htm"); + VALID_LINKS.add("fisherman/fish_appearance_exchange.htm"); + VALID_LINKS.add("fisherman/fishing_manual001.htm"); + VALID_LINKS.add("fisherman/fishing_manual002.htm"); + VALID_LINKS.add("fisherman/fishing_manual003.htm"); + VALID_LINKS.add("fisherman/fishing_manual004.htm"); + VALID_LINKS.add("fisherman/fishing_manual008.htm"); + VALID_LINKS.add("fisherman/fishing_manual009.htm"); + VALID_LINKS.add("fisherman/fishing_manual010.htm"); + VALID_LINKS.add("fortress/foreman.htm"); + VALID_LINKS.add("guard/kamaloka_help.htm"); + VALID_LINKS.add("guard/kamaloka_level.htm"); + VALID_LINKS.add("petmanager/evolve.htm"); + VALID_LINKS.add("petmanager/exchange.htm"); + VALID_LINKS.add("petmanager/instructions.htm"); + VALID_LINKS.add("teleporter/separatedsoul.htm"); + VALID_LINKS.add("warehouse/clanwh.htm"); + VALID_LINKS.add("warehouse/privatewh.htm"); + } @Override public boolean useBypass(String command, Player player, Creature target) @@ -92,12 +95,13 @@ public class Link implements IBypassHandler return false; } - String content = CommonUtil.contains(VALID_LINKS, htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; + String content = VALID_LINKS.contains(htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; // Precaution. if (htmlPath.startsWith("teleporter/") && !(player.getTarget() instanceof Teleporter)) { content = null; } + final NpcHtmlMessage html = new NpcHtmlMessage(target != null ? target.getObjectId() : 0); if (content != null) { diff --git a/L2J_Mobius_03.0_Helios/dist/game/data/scripts/handlers/itemhandlers/PetFood.java b/L2J_Mobius_03.0_Helios/dist/game/data/scripts/handlers/itemhandlers/PetFood.java index 3c5572d4ec..8b908ea095 100644 --- a/L2J_Mobius_03.0_Helios/dist/game/data/scripts/handlers/itemhandlers/PetFood.java +++ b/L2J_Mobius_03.0_Helios/dist/game/data/scripts/handlers/itemhandlers/PetFood.java @@ -17,6 +17,7 @@ package handlers.itemhandlers; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.PetDataTable; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -79,7 +80,7 @@ public class PetFood implements IItemHandler final Player player = activeChar.getActingPlayer(); if (player.isMounted()) { - final List foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); + final Set foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); if (foodIds.contains(item.getId()) && player.destroyItem("Consume", item.getObjectId(), 1, null, false)) { player.broadcastPacket(new MagicSkillUse(player, player, skillId, skillLevel, 0, 0)); diff --git a/L2J_Mobius_03.0_Helios/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java b/L2J_Mobius_03.0_Helios/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java index 2ad282f683..99f45fbb41 100644 --- a/L2J_Mobius_03.0_Helios/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java +++ b/L2J_Mobius_03.0_Helios/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.ClanHallData; import org.l2jmobius.gameserver.model.StatSet; @@ -32,12 +33,12 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpCheckResidenceSkillCondition implements ISkillCondition { - private final List _residencesId; + private final Set _residencesId = new HashSet<>(); private final boolean _isWithin; public OpCheckResidenceSkillCondition(StatSet params) { - _residencesId = params.getList("residencesId", Integer.class); + _residencesId.addAll(params.getList("residencesId", Integer.class)); _isWithin = params.getBoolean("isWithin"); } diff --git a/L2J_Mobius_03.0_Helios/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java b/L2J_Mobius_03.0_Helios/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java index fc2934423b..4a8282d988 100644 --- a/L2J_Mobius_03.0_Helios/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java +++ b/L2J_Mobius_03.0_Helios/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java @@ -16,9 +16,9 @@ */ package handlers.skillconditionhandlers; -import java.util.ArrayList; -import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -28,18 +28,18 @@ import org.l2jmobius.gameserver.model.skill.ISkillCondition; import org.l2jmobius.gameserver.model.skill.Skill; /** - * @author UnAfraid + * @author UnAfraid, Mobius */ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition { - private final List _npcIds = new ArrayList<>(); + private final Set _npcIds = new HashSet<>(); public OpNeedSummonOrPetSkillCondition(StatSet params) { - final List npcIds = params.getList("npcIds", String.class); + final List npcIds = params.getList("npcIds", Integer.class); if (npcIds != null) { - npcIds.stream().map(Integer::valueOf).forEach(_npcIds::add); + _npcIds.addAll(npcIds); } } @@ -47,7 +47,19 @@ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition public boolean canUse(Creature caster, Skill skill, WorldObject target) { final Summon pet = caster.getPet(); - final Collection summons = caster.getServitors().values(); - return ((pet != null) && _npcIds.stream().anyMatch(npcId -> npcId == pet.getId())) || summons.stream().anyMatch(summon -> _npcIds.contains(summon.getId())); + if ((pet != null) && _npcIds.contains(pet.getId())) + { + return true; + } + + for (Summon summon : caster.getServitors().values()) + { + if (_npcIds.contains(summon.getId())) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_03.0_Helios/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java b/L2J_Mobius_03.0_Helios/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java index 8541bc62b4..ef81b291d4 100644 --- a/L2J_Mobius_03.0_Helios/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java +++ b/L2J_Mobius_03.0_Helios/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,11 +30,11 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetDoorSkillCondition implements ISkillCondition { - private final List _doorIds; + private final Set _doorIds = new HashSet<>(); public OpTargetDoorSkillCondition(StatSet params) { - _doorIds = params.getList("doorIds", Integer.class); + _doorIds.addAll(params.getList("doorIds", Integer.class)); } @Override diff --git a/L2J_Mobius_03.0_Helios/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java b/L2J_Mobius_03.0_Helios/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java index 3ce4145703..0ccd571e19 100644 --- a/L2J_Mobius_03.0_Helios/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java +++ b/L2J_Mobius_03.0_Helios/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,17 +30,17 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetNpcSkillCondition implements ISkillCondition { - private final List _npcId; + private final Set _npcIds = new HashSet<>(); public OpTargetNpcSkillCondition(StatSet params) { - _npcId = params.getList("npcIds", Integer.class); + _npcIds.addAll(params.getList("npcIds", Integer.class)); } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget(); - return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId()); + return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcIds.contains(actualTarget.getId()); } } diff --git a/L2J_Mobius_03.0_Helios/dist/game/data/scripts/instances/AbstractInstance.java b/L2J_Mobius_03.0_Helios/dist/game/data/scripts/instances/AbstractInstance.java index 94c337f0df..a5b4ef238a 100644 --- a/L2J_Mobius_03.0_Helios/dist/game/data/scripts/instances/AbstractInstance.java +++ b/L2J_Mobius_03.0_Helios/dist/game/data/scripts/instances/AbstractInstance.java @@ -16,9 +16,10 @@ */ package instances; +import java.util.HashSet; import java.util.List; +import java.util.Set; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.enums.InstanceReenterType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.instancemanager.InstanceManager; @@ -40,25 +41,29 @@ import ai.AbstractNpcAI; */ public abstract class AbstractInstance extends AbstractNpcAI { - private final int[] _templateIds; + private final Set _templateIds = new HashSet<>(); - public AbstractInstance(int... templateId) + public AbstractInstance(int... templateIds) { - if (templateId.length == 0) + if (templateIds.length == 0) { throw new IllegalStateException("No template ids were provided!"); } - _templateIds = templateId; + + for (int templateId : templateIds) + { + _templateIds.add(templateId); + } } - public int[] getTemplateId() + public Set getTemplateId() { return _templateIds; } public boolean isInInstance(Instance instance) { - return (instance != null) && CommonUtil.contains(_templateIds, instance.getTemplateId()); + return (instance != null) && _templateIds.contains(instance.getTemplateId()); } /** diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/Config.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/Config.java index 03552971f1..d6959e5417 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/Config.java @@ -285,7 +285,7 @@ public class Config public static boolean AUTO_LOOT_SLOT_LIMIT; public static int LOOT_RAIDS_PRIVILEGE_INTERVAL; public static int LOOT_RAIDS_PRIVILEGE_CC_SIZE; - public static List AUTO_LOOT_ITEM_IDS; + public static Set AUTO_LOOT_ITEM_IDS; public static boolean ENABLE_KEYBOARD_MOVEMENT; public static int UNSTUCK_INTERVAL; public static int TELEPORT_WATCHDOG_TIMEOUT; @@ -461,7 +461,7 @@ public class Config public static boolean ALLOW_DISCARDITEM; public static int AUTODESTROY_ITEM_AFTER; public static int HERB_AUTO_DESTROY_TIME; - public static List LIST_PROTECTED_ITEMS; + public static Set LIST_PROTECTED_ITEMS; public static boolean DATABASE_CLEAN_UP; public static int CHAR_DATA_STORE_INTERVAL; public static int CLAN_VARIABLES_STORE_INTERVAL; @@ -559,7 +559,7 @@ public class Config public static boolean ALT_OLY_LOG_FIGHTS; public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS; public static boolean ALT_OLY_ANNOUNCE_GAMES; - public static List LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(); + public static Set LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(); public static int ALT_OLY_WEAPON_ENCHANT_LIMIT; public static int ALT_OLY_ARMOR_ENCHANT_LIMIT; public static int ALT_OLY_WAIT_TIME; @@ -1219,9 +1219,9 @@ public class Config public static int AUTO_CP_PERCENTAGE; public static int AUTO_HP_PERCENTAGE; public static int AUTO_MP_PERCENTAGE; - public static List AUTO_CP_ITEM_IDS; - public static List AUTO_HP_ITEM_IDS; - public static List AUTO_MP_ITEM_IDS; + public static Set AUTO_CP_ITEM_IDS; + public static Set AUTO_HP_ITEM_IDS; + public static Set AUTO_MP_ITEM_IDS; public static boolean CUSTOM_STARTING_LOC; public static int CUSTOM_STARTING_LOC_X; public static int CUSTOM_STARTING_LOC_Y; @@ -1231,7 +1231,7 @@ public class Config public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; public static int MOB_MIN_SPAWN_RANGE; public static int MOB_MAX_SPAWN_RANGE; - public static List MOBS_LIST_NOT_RANDOM; + public static Set MOBS_LIST_NOT_RANDOM; public static boolean FREE_JUMPS_FOR_ALL; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; @@ -1250,7 +1250,7 @@ public class Config public static boolean COMMUNITY_PREMIUM_SYSTEM_ENABLED; public static int COMMUNITY_PREMIUM_COIN_ID; public static int COMMUNITY_PREMIUM_PRICE_PER_DAY; - public static List COMMUNITY_AVAILABLE_BUFFS; + public static Set COMMUNITY_AVAILABLE_BUFFS; public static Map COMMUNITY_AVAILABLE_TELEPORTS; public static boolean CUSTOM_DEPOSITABLE_ENABLED; public static boolean CUSTOM_DEPOSITABLE_QUEST_ITEMS; @@ -1901,7 +1901,7 @@ public class Config LOOT_RAIDS_PRIVILEGE_INTERVAL = characterConfig.getInt("RaidLootRightsInterval", 900) * 1000; LOOT_RAIDS_PRIVILEGE_CC_SIZE = characterConfig.getInt("RaidLootRightsCCSize", 45); final String[] autoLootItemIds = characterConfig.getString("AutoLootItemIds", "0").split(","); - AUTO_LOOT_ITEM_IDS = new ArrayList<>(autoLootItemIds.length); + AUTO_LOOT_ITEM_IDS = new HashSet<>(autoLootItemIds.length); for (String item : autoLootItemIds) { Integer itm = 0; @@ -2021,7 +2021,7 @@ public class Config AUTODESTROY_ITEM_AFTER = generalConfig.getInt("AutoDestroyDroppedItemAfter", 600); HERB_AUTO_DESTROY_TIME = generalConfig.getInt("AutoDestroyHerbTime", 60) * 1000; final String[] split = generalConfig.getString("ListOfProtectedItems", "0").split(","); - LIST_PROTECTED_ITEMS = new ArrayList<>(split.length); + LIST_PROTECTED_ITEMS = new HashSet<>(split.length); for (String id : split) { LIST_PROTECTED_ITEMS.add(Integer.parseInt(id)); @@ -2424,7 +2424,7 @@ public class Config if (!olyRestrictedItems.isEmpty()) { final String[] olyRestrictedItemsSplit = olyRestrictedItems.split(","); - LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(olyRestrictedItemsSplit.length); + LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(olyRestrictedItemsSplit.length); for (String id : olyRestrictedItemsSplit) { LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id)); @@ -2577,17 +2577,17 @@ public class Config AUTO_CP_PERCENTAGE = autoPotionsConfig.getInt("AutoCpPercentage", 70); AUTO_HP_PERCENTAGE = autoPotionsConfig.getInt("AutoHpPercentage", 70); AUTO_MP_PERCENTAGE = autoPotionsConfig.getInt("AutoMpPercentage", 70); - AUTO_CP_ITEM_IDS = new ArrayList<>(); + AUTO_CP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoCpItemIds", "0").split(",")) { AUTO_CP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_HP_ITEM_IDS = new ArrayList<>(); + AUTO_HP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoHpItemIds", "0").split(",")) { AUTO_HP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_MP_ITEM_IDS = new ArrayList<>(); + AUTO_MP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoMpItemIds", "0").split(",")) { AUTO_MP_ITEM_IDS.add(Integer.parseInt(s)); @@ -3198,7 +3198,7 @@ public class Config COMMUNITY_PREMIUM_COIN_ID = communityBoardConfig.getInt("CommunityPremiumBuyCoinId", 57); COMMUNITY_PREMIUM_PRICE_PER_DAY = communityBoardConfig.getInt("CommunityPremiumPricePerDay", 1000000); final String[] allowedBuffs = communityBoardConfig.getString("CommunityAvailableBuffs", "").split(","); - COMMUNITY_AVAILABLE_BUFFS = new ArrayList<>(allowedBuffs.length); + COMMUNITY_AVAILABLE_BUFFS = new HashSet<>(allowedBuffs.length); for (String s : allowedBuffs) { COMMUNITY_AVAILABLE_BUFFS.add(Integer.parseInt(s)); @@ -3505,7 +3505,7 @@ public class Config if (ENABLE_RANDOM_MONSTER_SPAWNS) { final String[] mobsIds = randomSpawnsConfig.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); - MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + MOBS_LIST_NOT_RANDOM = new HashSet<>(mobsIds.length); for (String id : mobsIds) { MOBS_LIST_NOT_RANDOM.add(Integer.parseInt(id)); diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java index d6e0183c6f..c3977185b4 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java @@ -202,8 +202,7 @@ public class ClanHallData implements IXmlReader final Door door = DoorData.getInstance().getDoor(doorId); for (ClanHall ch : _clanHalls.values()) { - final List doors = ch.getDoors(); - if ((doors != null) && doors.contains(door)) + if (ch.getDoors().contains(door)) { return ch; } diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java index 6aa0a1fdde..fb395b9e2d 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java @@ -17,10 +17,10 @@ package org.l2jmobius.gameserver.data.xml; import java.io.File; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -42,7 +42,7 @@ public class FakePlayerData implements IXmlReader private final Map _fakePlayerInfos = new HashMap<>(); private final Map _fakePlayerNames = new HashMap<>(); private final Map _fakePlayerIds = new HashMap<>(); - private final List _talkableFakePlayerNames = new ArrayList<>(); + private final Set _talkableFakePlayerNames = new HashSet<>(); protected FakePlayerData() { diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java index d335b95954..1122d7b9ba 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java @@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -49,7 +51,7 @@ import org.l2jmobius.gameserver.util.Util; public class SellBuffsManager implements IXmlReader { private static final Logger LOGGER = Logger.getLogger(SellBuffsManager.class.getName()); - private static final List ALLOWED_BUFFS = new ArrayList<>(); + private static final Set ALLOWED_BUFFS = new HashSet<>(); private static final String HTML_FOLDER = "data/html/mods/SellBuffs/"; protected SellBuffsManager() @@ -76,11 +78,7 @@ public class SellBuffsManager implements IXmlReader { final Element elem = (Element) node.item(i); final int skillId = Integer.parseInt(elem.getAttribute("id")); - - if (!ALLOWED_BUFFS.contains(skillId)) - { - ALLOWED_BUFFS.add(skillId); - } + ALLOWED_BUFFS.add(skillId); } } diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java index b10f75ef3d..1e45a21319 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java @@ -19,8 +19,10 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; @@ -67,7 +69,7 @@ public class WalkingManager implements IXmlReader public static final byte REPEAT_TELE_FIRST = 2; public static final byte REPEAT_RANDOM = 3; - private final List _targetedNpcIds = new ArrayList<>(); + private final Set _targetedNpcIds = new HashSet<>(); private final Map _routes = new HashMap<>(); // all available routes private final Map _activeRoutes = new HashMap<>(); // each record represents NPC, moving by predefined route from _routes, and moving progress private final Map _routesToAttach = new HashMap<>(); // each record represents NPC and all available routes for it diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/BlockList.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/BlockList.java index 1af9941ed5..9ac6266e22 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/BlockList.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/BlockList.java @@ -19,9 +19,9 @@ package org.l2jmobius.gameserver.model; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -36,10 +36,11 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; public class BlockList { private static final Logger LOGGER = Logger.getLogger(BlockList.class.getName()); - private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); + + private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); private final Player _owner; - private List _blockList; + private Set _blockList; public BlockList(Player owner) { @@ -68,9 +69,9 @@ public class BlockList OFFLINE_LIST.put(_owner.getObjectId(), _blockList); } - private static List loadList(int objId) + private static Set loadList(int objId) { - final List list = new ArrayList<>(); + final Set list = new HashSet<>(); try (Connection con = DatabaseFactory.getConnection(); PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1")) { @@ -158,7 +159,7 @@ public class BlockList _owner.setMessageRefusal(value); } - private List getBlockList() + private Set getBlockList() { return _blockList; } diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/PetData.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/PetData.java index b534c21f36..231b85e85f 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/PetData.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/PetData.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; import org.l2jmobius.gameserver.model.holders.SkillHolder; @@ -40,7 +42,7 @@ public class PetData private int _minLevel = Byte.MAX_VALUE; private int _maxLevel = 0; private boolean _syncLevel = false; - private final List _food = new ArrayList<>(); + private final Set _food = new HashSet<>(); public PetData(int npcId, int itemId) { @@ -133,7 +135,7 @@ public class PetData /** * @return the pet's food list. */ - public List getFood() + public Set getFood() { return _food; } diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/SkillLearn.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/SkillLearn.java index a69d30f105..3d5704b5f2 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/SkillLearn.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/SkillLearn.java @@ -16,9 +16,8 @@ */ package org.l2jmobius.gameserver.model; -import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashSet; -import java.util.List; import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -40,12 +39,12 @@ public class SkillLearn private final int _getDualClassLevel; private final boolean _autoGet; private final long _levelUpSp; - private final List _requiredItems = new ArrayList<>(); - private final List _races = new ArrayList<>(); - private final List _preReqSkills = new ArrayList<>(); + private final Set _requiredItems = new HashSet<>(1); + private final Set _races = EnumSet.noneOf(Race.class); + private final Set _preReqSkills = new HashSet<>(1); private SocialClass _socialClass; private final boolean _residenceSkill; - private final List _residenceIds = new ArrayList<>(); + private final Set _residenceIds = new HashSet<>(1); private final boolean _learnedByNpc; private final boolean _learnedByFS; private final Set _removeSkills = new HashSet<>(1); @@ -133,9 +132,9 @@ public class SkillLearn } /** - * @return the list with the item holders required to acquire this skill. + * @return the set with the item holders required to acquire this skill. */ - public List getRequiredItems() + public Set getRequiredItems() { return _requiredItems; } @@ -150,9 +149,9 @@ public class SkillLearn } /** - * @return a list with the races that can acquire this skill. + * @return a set with the races that can acquire this skill. */ - public List getRaces() + public Set getRaces() { return _races; } @@ -167,9 +166,9 @@ public class SkillLearn } /** - * @return the list of skill holders required to acquire this skill. + * @return the set of skill holders required to acquire this skill. */ - public List getPreReqSkills() + public Set getPreReqSkills() { return _preReqSkills; } @@ -212,9 +211,9 @@ public class SkillLearn } /** - * @return a list with the Ids where this skill is available. + * @return a set with the Ids where this skill is available. */ - public List getResidenceIds() + public Set getResidenceIds() { return _residenceIds; } diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java index d80071ca22..b088c8b8c9 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java @@ -22,7 +22,6 @@ import java.sql.ResultSet; import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.List; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; @@ -153,7 +152,7 @@ public class Pet extends Summon broadcastStatusUpdate(); - final List foodIds = getPetData().getFood(); + final Set foodIds = getPetData().getFood(); if (foodIds.isEmpty()) { if (isUncontrollable()) diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java index 11efe435d8..1ed0ee81a4 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java @@ -16,8 +16,8 @@ */ package org.l2jmobius.gameserver.model.actor.instance; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import org.l2jmobius.commons.threads.ThreadPool; @@ -57,7 +57,7 @@ public class Trap extends Npc private boolean _isTriggered; private final int _lifeTime; private Player _owner; - private final List _playersWhoDetectedMe = new ArrayList<>(); + private final Set _playersWhoDetectedMe = new HashSet<>(); private final SkillHolder _skill; private int _remainingTime; // Tasks diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java index 71ef076212..3ba8c20a9b 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor.tasks.player; -import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -69,11 +69,12 @@ public class PetFeedTask implements Runnable _player.sendPacket(SystemMessageId.YOU_ARE_OUT_OF_FEED_MOUNT_STATUS_CANCELED); } - final List foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); + final Set foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); if (foodIds.isEmpty()) { return; } + Item food = null; for (int id : foodIds) { diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java index 50d2a821c3..2611b5f121 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.actor.Creature; @@ -29,9 +29,9 @@ import org.l2jmobius.gameserver.model.zone.ZoneType; */ public class ConditionPlayerInsideZoneId extends Condition { - private final List _zones; + private final Set _zones; - public ConditionPlayerInsideZoneId(List zones) + public ConditionPlayerInsideZoneId(Set zones) { _zones = zones; } diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java index c15065eca2..d644f663f5 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Player; @@ -29,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerInstanceId extends Condition { - private final List _instanceIds; + private final Set _instanceIds; /** * Instantiates a new condition player instance id. * @param instanceIds the instance ids */ - public ConditionPlayerInstanceId(List instanceIds) + public ConditionPlayerInstanceId(Set instanceIds) { _instanceIds = instanceIds; } diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java index 14d61089ed..7c375ec45e 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -28,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerRace extends Condition { - private final Race[] _races; + private final Set _races; /** * Instantiates a new condition player race. * @param races the list containing the allowed races. */ - public ConditionPlayerRace(Race[] races) + public ConditionPlayerRace(Set races) { _races = races; } @@ -46,6 +47,6 @@ public class ConditionPlayerRace extends Condition { return false; } - return CommonUtil.contains(_races, effector.getActingPlayer().getRace()); + return _races.contains(effector.getActingPlayer().getRace()); } } diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java index 0f54766571..0b326e3f40 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId())) + if (_npcIds.contains(target.getId())) { existNpc = true; break; diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java index c5c9b5ff0e..db64b6bd7b 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromSummonedNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromSummonedNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromSummonedNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromSummonedNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId()) && (effector == target.getSummoner())) + if (_npcIds.contains(target.getId()) && (effector == target.getSummoner())) { existNpc = true; break; diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java index a3fb0f5374..a47b4b4983 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetClassIdRestriction extends Condition { - private final List _classIds; + private final Set _classIds; /** * Instantiates a new condition target class id restriction. * @param classId the class id */ - public ConditionTargetClassIdRestriction(List classId) + public ConditionTargetClassIdRestriction(Set classId) { _classIds = classId; } diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java index 82b1bd5877..9bb694f4ef 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetNpcId extends Condition { - private final List _npcIds; + private final Set _npcIds; /** * Instantiates a new condition target npc id. * @param npcIds the npc ids */ - public ConditionTargetNpcId(List npcIds) + public ConditionTargetNpcId(Set npcIds) { _npcIds = npcIds; } diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java index f26329bc21..5c86f26ae5 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.holders; -import java.util.Collection; +import java.util.Set; /** * @author Mobius @@ -25,9 +25,9 @@ public class EventDropHolder extends DropHolder { private final int _minLevel; private final int _maxLevel; - private final Collection _monsterIds; + private final Set _monsterIds; - public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Collection monsterIds) + public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Set monsterIds) { super(null, itemId, min, max, chance); _minLevel = minLevel; @@ -45,7 +45,7 @@ public class EventDropHolder extends DropHolder return _maxLevel; } - public Collection getMonsterIds() + public Set getMonsterIds() { return _monsterIds; } diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/item/Henna.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/item/Henna.java index af805ac1bc..6c2c9feea3 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/item/Henna.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/item/Henna.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model.item; import java.util.ArrayList; import java.util.EnumMap; +import java.util.EnumSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.enums.ClassId; import org.l2jmobius.gameserver.model.StatSet; @@ -42,7 +44,7 @@ public class Henna private final int _cancelCount; private final int _duration; private final List _skills; - private final List _wearClass; + private final Set _wearClass; public Henna(StatSet set) { @@ -63,7 +65,7 @@ public class Henna _cancelCount = set.getInt("cancel_count"); _duration = set.getInt("duration", -1); _skills = new ArrayList<>(); - _wearClass = new ArrayList<>(); + _wearClass = EnumSet.noneOf(ClassId.class); } /** @@ -159,7 +161,7 @@ public class Henna /** * @return the list with the allowed classes to wear this dye. */ - public List getAllowedWearClass() + public Set getAllowedWearClass() { return _wearClass; } diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java index 18d7b61ca2..65402c4c89 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java @@ -17,9 +17,10 @@ package org.l2jmobius.gameserver.model.item.appearance; import java.time.Duration; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.enums.Race; @@ -47,12 +48,12 @@ public class AppearanceStone private final ArmorType _armorType; private final AppearanceHandType _handType; private final AppearanceMagicType _magicType; - private List _crystalTypes; - private List _targetTypes; - private List _bodyParts; - private List _races; - private List _racesNot; - private List _allVisualIds; + private Set _crystalTypes; + private Set _targetTypes; + private Set _bodyParts; + private Set _races; + private Set _racesNot; + private Set _allVisualIds; public AppearanceStone(StatSet set) { @@ -172,35 +173,35 @@ public class AppearanceStone { if (_crystalTypes == null) { - _crystalTypes = new ArrayList<>(); + _crystalTypes = EnumSet.noneOf(CrystalType.class); } _crystalTypes.add(type); } - public List getCrystalTypes() + public Set getCrystalTypes() { - return _crystalTypes != null ? _crystalTypes : Collections.emptyList(); + return _crystalTypes != null ? _crystalTypes : Collections.emptySet(); } public void addTargetType(AppearanceTargetType type) { if (_targetTypes == null) { - _targetTypes = new ArrayList<>(); + _targetTypes = EnumSet.noneOf(AppearanceTargetType.class); } _targetTypes.add(type); } - public List getTargetTypes() + public Set getTargetTypes() { - return _targetTypes != null ? _targetTypes : Collections.emptyList(); + return _targetTypes != null ? _targetTypes : Collections.emptySet(); } public void addBodyPart(Integer part) { if (_bodyParts == null) { - _bodyParts = new ArrayList<>(); + _bodyParts = new HashSet<>(); } _bodyParts.add(part); } @@ -209,47 +210,47 @@ public class AppearanceStone { if (_allVisualIds == null) { - _allVisualIds = new ArrayList<>(); + _allVisualIds = new HashSet<>(); } _allVisualIds.add(appearanceHolder); } - public List getVisualIds() + public Set getVisualIds() { - return _allVisualIds != null ? _allVisualIds : Collections.emptyList(); + return _allVisualIds != null ? _allVisualIds : Collections.emptySet(); } - public List getBodyParts() + public Set getBodyParts() { - return _bodyParts != null ? _bodyParts : Collections.emptyList(); + return _bodyParts != null ? _bodyParts : Collections.emptySet(); } public void addRace(Race race) { if (_races == null) { - _races = new ArrayList<>(); + _races = EnumSet.noneOf(Race.class); } _races.add(race); } - public List getRaces() + public Set getRaces() { - return _races != null ? _races : Collections.emptyList(); + return _races != null ? _races : Collections.emptySet(); } public void addRaceNot(Race race) { if (_racesNot == null) { - _racesNot = new ArrayList<>(); + _racesNot = EnumSet.noneOf(Race.class); } _racesNot.add(race); } - public List getRacesNot() + public Set getRacesNot() { - return _racesNot != null ? _racesNot : Collections.emptyList(); + return _racesNot != null ? _racesNot : Collections.emptySet(); } /** @@ -302,7 +303,7 @@ public class AppearanceStone { // Seems like in retail item with already changed appearance, can be changed again without being restored. - final AppearanceTargetType targetType = getTargetTypes().get(0); + final AppearanceTargetType targetType = getTargetTypes().stream().findFirst().get(); switch (targetType) { case NONE: diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java index 5d3a79d524..5e067a67e5 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java @@ -16,16 +16,16 @@ */ package org.l2jmobius.gameserver.model.item.enchant; +import java.util.EnumSet; +import java.util.Set; import java.util.logging.Logger; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.item.ItemTemplate; import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.model.item.type.CrystalType; import org.l2jmobius.gameserver.model.item.type.EtcItemType; -import org.l2jmobius.gameserver.model.item.type.ItemType; /** * @author UnAfraid @@ -34,26 +34,27 @@ public abstract class AbstractEnchantItem { protected static final Logger LOGGER = Logger.getLogger(AbstractEnchantItem.class.getName()); - private static final ItemType[] ENCHANT_TYPES = new ItemType[] + private static final Set ENCHANT_TYPES = EnumSet.noneOf(EtcItemType.class); + static { - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM, - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP, - EtcItemType.BLESS_ENCHT_AM, - EtcItemType.BLESS_ENCHT_AM_DOWN, - EtcItemType.BLESS_ENCHT_WP, - EtcItemType.ENCHT_AM, - EtcItemType.ENCHT_WP, - EtcItemType.GIANT_ENCHT_AM, - EtcItemType.GIANT_ENCHT_WP, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - }; + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + } private final int _id; private final CrystalType _grade; @@ -71,7 +72,7 @@ public abstract class AbstractEnchantItem { throw new NullPointerException(); } - else if (!CommonUtil.contains(ENCHANT_TYPES, getItem().getItemType())) + else if (!ENCHANT_TYPES.contains(getItem().getItemType())) { throw new IllegalAccessError(); } diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java index 5ba6755084..18508d0145 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java @@ -24,8 +24,10 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Set; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -184,7 +186,7 @@ public class LongTimeEvent extends Quest final Node maxLevelNode = d.getAttributes().getNamedItem("maxLevel"); final int maxLevel = maxLevelNode == null ? Integer.MAX_VALUE : Integer.parseInt(maxLevelNode.getNodeValue()); final Node monsterIdsNode = d.getAttributes().getNamedItem("monsterIds"); - final List monsterIds = new ArrayList<>(); + final Set monsterIds = new HashSet<>(); if (monsterIdsNode != null) { for (String id : monsterIdsNode.getNodeValue().split(",")) diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/residences/ClanHall.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/residences/ClanHall.java index 0c0a529077..fcc850371b 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/residences/ClanHall.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/residences/ClanHall.java @@ -23,7 +23,9 @@ import java.sql.SQLException; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -61,9 +63,9 @@ public class ClanHall extends AbstractResidence private final int _minBid; final int _lease; private final int _deposit; - private final List _npcs; - private final List _doors; - private final List _teleports; + private final Set _npcs = new HashSet<>(); + private final Set _doors = new HashSet<>(); + private final Set _teleports = new HashSet<>(); private final Location _ownerLocation; private final Location _banishLocation; // Dynamic parameters @@ -85,9 +87,21 @@ public class ClanHall extends AbstractResidence _minBid = params.getInt("minBid"); _lease = params.getInt("lease"); _deposit = params.getInt("deposit"); - _npcs = params.getList("npcList", Integer.class); - _doors = params.getList("doorList", Door.class); - _teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + final List npcs = params.getList("npcList", Integer.class); + if (npcs != null) + { + _npcs.addAll(npcs); + } + final List doors = params.getList("doorList", Door.class); + if (doors != null) + { + _doors.addAll(doors); + } + final List teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + if (teleports != null) + { + _teleports.addAll(teleports); + } _ownerLocation = params.getLocation("owner_loc"); _banishLocation = params.getLocation("banish_loc"); // Set dynamic parameters (from DB) @@ -196,7 +210,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Door} related to this {@link ClanHall}. * @return all {@link Door} related to this {@link ClanHall} */ - public List getDoors() + public Set getDoors() { return _doors; } @@ -205,7 +219,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Npc} related to this {@link ClanHall}. * @return all {@link Npc} related to this {@link ClanHall} */ - public List getNpcs() + public Set getNpcs() { return _npcs; } @@ -324,7 +338,7 @@ public class ClanHall extends AbstractResidence return _banishLocation; } - public List getTeleportList() + public Set getTeleportList() { return _teleports; } diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/siege/Castle.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/siege/Castle.java index 9f883b28a1..30a0c5b33b 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/siege/Castle.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/siege/Castle.java @@ -21,8 +21,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.Calendar; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -82,7 +84,7 @@ public class Castle extends AbstractResidence private SiegeZone _zone = null; private ResidenceTeleportZone _teleZone; private Clan _formerOwner = null; - private final List _artefacts = new ArrayList<>(1); + private final Set _artefacts = new HashSet<>(1); private final Map _function = new ConcurrentHashMap<>(); private int _ticketBuyCount = 0; private boolean _isFirstMidVictory = false; @@ -1071,7 +1073,7 @@ public class Castle extends AbstractResidence _artefacts.add(artefact); } - public List getArtefacts() + public Set getArtefacts() { return _artefacts; } diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java index 0c79677eae..4ebf954ee5 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.network.serverpackets; -import java.util.List; +import java.util.Set; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.gameserver.data.sql.CharNameTable; @@ -27,19 +27,19 @@ import org.l2jmobius.gameserver.network.OutgoingPackets; */ public class BlockListPacket implements IClientOutgoingPacket { - private final List _playersId; + private final Set _playerIds; - public BlockListPacket(List playersId) + public BlockListPacket(Set playerIds) { - _playersId = playersId; + _playerIds = playerIds; } @Override public boolean write(PacketWriter packet) { OutgoingPackets.BLOCK_LIST.writeId(packet); - packet.writeD(_playersId.size()); - for (int playerId : _playersId) + packet.writeD(_playerIds.size()); + for (int playerId : _playerIds) { packet.writeS(CharNameTable.getInstance().getNameById(playerId)); packet.writeS(""); // memo ? diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java index 8555bb6e86..eb5bfd05d8 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.network.serverpackets; import java.util.List; import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; import org.l2jmobius.commons.network.PacketWriter; @@ -37,7 +38,7 @@ public class ExAcquireSkillInfo implements IClientOutgoingPacket private final int _dualClassLevel; private final long _spCost; private final int _minLevel; - private final List _itemReq; + private final Set _itemReq; private final List _skillRem; /** diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java index 84b5fead76..a163a85735 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java @@ -35,7 +35,7 @@ public class ExChooseShapeShiftingItem implements IClientOutgoingPacket public ExChooseShapeShiftingItem(AppearanceStone stone) { _type = stone.getType(); - _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().get(0); + _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().stream().findFirst().get(); _itemId = stone.getId(); } diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/util/DocumentBase.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/util/DocumentBase.java index 8a8e13d940..c22140b9c4 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/util/DocumentBase.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/util/DocumentBase.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.util; import java.io.File; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -390,12 +391,12 @@ public abstract class DocumentBase case "races": { final String[] racesVal = a.getNodeValue().split(","); - final Race[] races = new Race[racesVal.length]; + final Set races = EnumSet.noneOf(Race.class); for (int r = 0; r < racesVal.length; r++) { if (racesVal[r] != null) { - races[r] = Race.valueOf(racesVal[r]); + races.add(Race.valueOf(racesVal[r])); } } cond = joinAnd(cond, new ConditionPlayerRace(races)); @@ -671,13 +672,13 @@ public abstract class DocumentBase case "instanceid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final ArrayList array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInstanceId(array)); + cond = joinAnd(cond, new ConditionPlayerInstanceId(set)); break; } case "agathionid": @@ -728,10 +729,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -745,10 +746,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -834,13 +835,13 @@ public abstract class DocumentBase case "insidezoneid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInsideZoneId(array)); + cond = joinAnd(cond, new ConditionPlayerInsideZoneId(set)); break; } case "checkabnormal": @@ -961,13 +962,13 @@ public abstract class DocumentBase case "class_id_restriction": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetClassIdRestriction(array)); + cond = joinAnd(cond, new ConditionTargetClassIdRestriction(set)); break; } case "active_effect_id": @@ -1045,13 +1046,13 @@ public abstract class DocumentBase case "npcid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetNpcId(array)); + cond = joinAnd(cond, new ConditionTargetNpcId(set)); break; } case "npctype": diff --git a/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/handlers/bypasshandlers/Link.java b/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/handlers/bypasshandlers/Link.java index 2fdb263f0d..988a6c499f 100644 --- a/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/handlers/bypasshandlers/Link.java +++ b/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/handlers/bypasshandlers/Link.java @@ -16,7 +16,9 @@ */ package handlers.bypasshandlers; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.HashSet; +import java.util.Set; + import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.handler.IBypassHandler; import org.l2jmobius.gameserver.model.actor.Creature; @@ -31,50 +33,51 @@ public class Link implements IBypassHandler "Link" }; - private static final String[] VALID_LINKS = + private static final Set VALID_LINKS = new HashSet<>(); + static { - "common/attribute_info.htm", - "common/augmentation_01.htm", - "common/augmentation_02.htm", - "common/augmentation_exchange.htm", - "common/crafting_01.htm", - "common/crafting_02.htm", - "common/crafting_03.htm", - "common/cursed_to_unidentified.htm", - "common/duals_01.htm", - "common/duals_02.htm", - "common/duals_03.htm", - "common/g_cube_warehouse001.htm", - "common/skill_enchant_help.htm", - "common/skill_enchant_help_01.htm", - "common/skill_enchant_help_02.htm", - "common/skill_enchant_help_03.htm", - "common/smelting_trade001.htm", - "common/weapon_sa_01.htm", - "common/welcomeback002.htm", - "common/welcomeback003.htm", - "default/BlessingOfProtection.htm", - "default/SupportMagic.htm", - "default/SupportMagicServitor.htm", - "fisherman/exchange_old_items.htm", - "fisherman/fish_appearance_exchange.htm", - "fisherman/fishing_manual001.htm", - "fisherman/fishing_manual002.htm", - "fisherman/fishing_manual003.htm", - "fisherman/fishing_manual004.htm", - "fisherman/fishing_manual008.htm", - "fisherman/fishing_manual009.htm", - "fisherman/fishing_manual010.htm", - "fortress/foreman.htm", - "guard/kamaloka_help.htm", - "guard/kamaloka_level.htm", - "petmanager/evolve.htm", - "petmanager/exchange.htm", - "petmanager/instructions.htm", - "teleporter/separatedsoul.htm", - "warehouse/clanwh.htm", - "warehouse/privatewh.htm", - }; + VALID_LINKS.add("common/attribute_info.htm"); + VALID_LINKS.add("common/augmentation_01.htm"); + VALID_LINKS.add("common/augmentation_02.htm"); + VALID_LINKS.add("common/augmentation_exchange.htm"); + VALID_LINKS.add("common/crafting_01.htm"); + VALID_LINKS.add("common/crafting_02.htm"); + VALID_LINKS.add("common/crafting_03.htm"); + VALID_LINKS.add("common/cursed_to_unidentified.htm"); + VALID_LINKS.add("common/duals_01.htm"); + VALID_LINKS.add("common/duals_02.htm"); + VALID_LINKS.add("common/duals_03.htm"); + VALID_LINKS.add("common/g_cube_warehouse001.htm"); + VALID_LINKS.add("common/skill_enchant_help.htm"); + VALID_LINKS.add("common/skill_enchant_help_01.htm"); + VALID_LINKS.add("common/skill_enchant_help_02.htm"); + VALID_LINKS.add("common/skill_enchant_help_03.htm"); + VALID_LINKS.add("common/smelting_trade001.htm"); + VALID_LINKS.add("common/weapon_sa_01.htm"); + VALID_LINKS.add("common/welcomeback002.htm"); + VALID_LINKS.add("common/welcomeback003.htm"); + VALID_LINKS.add("default/BlessingOfProtection.htm"); + VALID_LINKS.add("default/SupportMagic.htm"); + VALID_LINKS.add("default/SupportMagicServitor.htm"); + VALID_LINKS.add("fisherman/exchange_old_items.htm"); + VALID_LINKS.add("fisherman/fish_appearance_exchange.htm"); + VALID_LINKS.add("fisherman/fishing_manual001.htm"); + VALID_LINKS.add("fisherman/fishing_manual002.htm"); + VALID_LINKS.add("fisherman/fishing_manual003.htm"); + VALID_LINKS.add("fisherman/fishing_manual004.htm"); + VALID_LINKS.add("fisherman/fishing_manual008.htm"); + VALID_LINKS.add("fisherman/fishing_manual009.htm"); + VALID_LINKS.add("fisherman/fishing_manual010.htm"); + VALID_LINKS.add("fortress/foreman.htm"); + VALID_LINKS.add("guard/kamaloka_help.htm"); + VALID_LINKS.add("guard/kamaloka_level.htm"); + VALID_LINKS.add("petmanager/evolve.htm"); + VALID_LINKS.add("petmanager/exchange.htm"); + VALID_LINKS.add("petmanager/instructions.htm"); + VALID_LINKS.add("teleporter/separatedsoul.htm"); + VALID_LINKS.add("warehouse/clanwh.htm"); + VALID_LINKS.add("warehouse/privatewh.htm"); + } @Override public boolean useBypass(String command, Player player, Creature target) @@ -92,12 +95,13 @@ public class Link implements IBypassHandler return false; } - String content = CommonUtil.contains(VALID_LINKS, htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; + String content = VALID_LINKS.contains(htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; // Precaution. if (htmlPath.startsWith("teleporter/") && !(player.getTarget() instanceof Teleporter)) { content = null; } + final NpcHtmlMessage html = new NpcHtmlMessage(target != null ? target.getObjectId() : 0); if (content != null) { diff --git a/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/handlers/itemhandlers/PetFood.java b/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/handlers/itemhandlers/PetFood.java index 3c5572d4ec..8b908ea095 100644 --- a/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/handlers/itemhandlers/PetFood.java +++ b/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/handlers/itemhandlers/PetFood.java @@ -17,6 +17,7 @@ package handlers.itemhandlers; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.PetDataTable; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -79,7 +80,7 @@ public class PetFood implements IItemHandler final Player player = activeChar.getActingPlayer(); if (player.isMounted()) { - final List foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); + final Set foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); if (foodIds.contains(item.getId()) && player.destroyItem("Consume", item.getObjectId(), 1, null, false)) { player.broadcastPacket(new MagicSkillUse(player, player, skillId, skillLevel, 0, 0)); diff --git a/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java b/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java index 2ad282f683..99f45fbb41 100644 --- a/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java +++ b/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.ClanHallData; import org.l2jmobius.gameserver.model.StatSet; @@ -32,12 +33,12 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpCheckResidenceSkillCondition implements ISkillCondition { - private final List _residencesId; + private final Set _residencesId = new HashSet<>(); private final boolean _isWithin; public OpCheckResidenceSkillCondition(StatSet params) { - _residencesId = params.getList("residencesId", Integer.class); + _residencesId.addAll(params.getList("residencesId", Integer.class)); _isWithin = params.getBoolean("isWithin"); } diff --git a/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java b/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java index fc2934423b..4a8282d988 100644 --- a/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java +++ b/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java @@ -16,9 +16,9 @@ */ package handlers.skillconditionhandlers; -import java.util.ArrayList; -import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -28,18 +28,18 @@ import org.l2jmobius.gameserver.model.skill.ISkillCondition; import org.l2jmobius.gameserver.model.skill.Skill; /** - * @author UnAfraid + * @author UnAfraid, Mobius */ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition { - private final List _npcIds = new ArrayList<>(); + private final Set _npcIds = new HashSet<>(); public OpNeedSummonOrPetSkillCondition(StatSet params) { - final List npcIds = params.getList("npcIds", String.class); + final List npcIds = params.getList("npcIds", Integer.class); if (npcIds != null) { - npcIds.stream().map(Integer::valueOf).forEach(_npcIds::add); + _npcIds.addAll(npcIds); } } @@ -47,7 +47,19 @@ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition public boolean canUse(Creature caster, Skill skill, WorldObject target) { final Summon pet = caster.getPet(); - final Collection summons = caster.getServitors().values(); - return ((pet != null) && _npcIds.stream().anyMatch(npcId -> npcId == pet.getId())) || summons.stream().anyMatch(summon -> _npcIds.contains(summon.getId())); + if ((pet != null) && _npcIds.contains(pet.getId())) + { + return true; + } + + for (Summon summon : caster.getServitors().values()) + { + if (_npcIds.contains(summon.getId())) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java b/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java index 8541bc62b4..ef81b291d4 100644 --- a/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java +++ b/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,11 +30,11 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetDoorSkillCondition implements ISkillCondition { - private final List _doorIds; + private final Set _doorIds = new HashSet<>(); public OpTargetDoorSkillCondition(StatSet params) { - _doorIds = params.getList("doorIds", Integer.class); + _doorIds.addAll(params.getList("doorIds", Integer.class)); } @Override diff --git a/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java b/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java index 3ce4145703..0ccd571e19 100644 --- a/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java +++ b/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,17 +30,17 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetNpcSkillCondition implements ISkillCondition { - private final List _npcId; + private final Set _npcIds = new HashSet<>(); public OpTargetNpcSkillCondition(StatSet params) { - _npcId = params.getList("npcIds", Integer.class); + _npcIds.addAll(params.getList("npcIds", Integer.class)); } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget(); - return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId()); + return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcIds.contains(actualTarget.getId()); } } diff --git a/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/instances/AbstractInstance.java b/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/instances/AbstractInstance.java index 94c337f0df..a5b4ef238a 100644 --- a/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/instances/AbstractInstance.java +++ b/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/instances/AbstractInstance.java @@ -16,9 +16,10 @@ */ package instances; +import java.util.HashSet; import java.util.List; +import java.util.Set; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.enums.InstanceReenterType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.instancemanager.InstanceManager; @@ -40,25 +41,29 @@ import ai.AbstractNpcAI; */ public abstract class AbstractInstance extends AbstractNpcAI { - private final int[] _templateIds; + private final Set _templateIds = new HashSet<>(); - public AbstractInstance(int... templateId) + public AbstractInstance(int... templateIds) { - if (templateId.length == 0) + if (templateIds.length == 0) { throw new IllegalStateException("No template ids were provided!"); } - _templateIds = templateId; + + for (int templateId : templateIds) + { + _templateIds.add(templateId); + } } - public int[] getTemplateId() + public Set getTemplateId() { return _templateIds; } public boolean isInInstance(Instance instance) { - return (instance != null) && CommonUtil.contains(_templateIds, instance.getTemplateId()); + return (instance != null) && _templateIds.contains(instance.getTemplateId()); } /** diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/Config.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/Config.java index 0a181f258b..2fda2748c1 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/Config.java @@ -279,7 +279,7 @@ public class Config public static boolean AUTO_LOOT_SLOT_LIMIT; public static int LOOT_RAIDS_PRIVILEGE_INTERVAL; public static int LOOT_RAIDS_PRIVILEGE_CC_SIZE; - public static List AUTO_LOOT_ITEM_IDS; + public static Set AUTO_LOOT_ITEM_IDS; public static boolean ENABLE_KEYBOARD_MOVEMENT; public static int UNSTUCK_INTERVAL; public static int TELEPORT_WATCHDOG_TIMEOUT; @@ -455,7 +455,7 @@ public class Config public static boolean ALLOW_DISCARDITEM; public static int AUTODESTROY_ITEM_AFTER; public static int HERB_AUTO_DESTROY_TIME; - public static List LIST_PROTECTED_ITEMS; + public static Set LIST_PROTECTED_ITEMS; public static boolean DATABASE_CLEAN_UP; public static int CHAR_DATA_STORE_INTERVAL; public static int CLAN_VARIABLES_STORE_INTERVAL; @@ -548,7 +548,7 @@ public class Config public static boolean ALT_OLY_LOG_FIGHTS; public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS; public static boolean ALT_OLY_ANNOUNCE_GAMES; - public static List LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(); + public static Set LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(); public static int ALT_OLY_WEAPON_ENCHANT_LIMIT; public static int ALT_OLY_ARMOR_ENCHANT_LIMIT; public static int ALT_OLY_WAIT_TIME; @@ -1206,9 +1206,9 @@ public class Config public static int AUTO_CP_PERCENTAGE; public static int AUTO_HP_PERCENTAGE; public static int AUTO_MP_PERCENTAGE; - public static List AUTO_CP_ITEM_IDS; - public static List AUTO_HP_ITEM_IDS; - public static List AUTO_MP_ITEM_IDS; + public static Set AUTO_CP_ITEM_IDS; + public static Set AUTO_HP_ITEM_IDS; + public static Set AUTO_MP_ITEM_IDS; public static boolean CUSTOM_STARTING_LOC; public static int CUSTOM_STARTING_LOC_X; public static int CUSTOM_STARTING_LOC_Y; @@ -1218,7 +1218,7 @@ public class Config public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; public static int MOB_MIN_SPAWN_RANGE; public static int MOB_MAX_SPAWN_RANGE; - public static List MOBS_LIST_NOT_RANDOM; + public static Set MOBS_LIST_NOT_RANDOM; public static boolean FREE_JUMPS_FOR_ALL; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; @@ -1237,7 +1237,7 @@ public class Config public static boolean COMMUNITY_PREMIUM_SYSTEM_ENABLED; public static int COMMUNITY_PREMIUM_COIN_ID; public static int COMMUNITY_PREMIUM_PRICE_PER_DAY; - public static List COMMUNITY_AVAILABLE_BUFFS; + public static Set COMMUNITY_AVAILABLE_BUFFS; public static Map COMMUNITY_AVAILABLE_TELEPORTS; public static boolean CUSTOM_DEPOSITABLE_ENABLED; public static boolean CUSTOM_DEPOSITABLE_QUEST_ITEMS; @@ -1882,7 +1882,7 @@ public class Config LOOT_RAIDS_PRIVILEGE_INTERVAL = characterConfig.getInt("RaidLootRightsInterval", 900) * 1000; LOOT_RAIDS_PRIVILEGE_CC_SIZE = characterConfig.getInt("RaidLootRightsCCSize", 45); final String[] autoLootItemIds = characterConfig.getString("AutoLootItemIds", "0").split(","); - AUTO_LOOT_ITEM_IDS = new ArrayList<>(autoLootItemIds.length); + AUTO_LOOT_ITEM_IDS = new HashSet<>(autoLootItemIds.length); for (String item : autoLootItemIds) { Integer itm = 0; @@ -2001,7 +2001,7 @@ public class Config AUTODESTROY_ITEM_AFTER = generalConfig.getInt("AutoDestroyDroppedItemAfter", 600); HERB_AUTO_DESTROY_TIME = generalConfig.getInt("AutoDestroyHerbTime", 60) * 1000; final String[] split = generalConfig.getString("ListOfProtectedItems", "0").split(","); - LIST_PROTECTED_ITEMS = new ArrayList<>(split.length); + LIST_PROTECTED_ITEMS = new HashSet<>(split.length); for (String id : split) { LIST_PROTECTED_ITEMS.add(Integer.parseInt(id)); @@ -2399,7 +2399,7 @@ public class Config if (!olyRestrictedItems.isEmpty()) { final String[] olyRestrictedItemsSplit = olyRestrictedItems.split(","); - LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(olyRestrictedItemsSplit.length); + LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(olyRestrictedItemsSplit.length); for (String id : olyRestrictedItemsSplit) { LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id)); @@ -2551,17 +2551,17 @@ public class Config AUTO_CP_PERCENTAGE = autoPotionsConfig.getInt("AutoCpPercentage", 70); AUTO_HP_PERCENTAGE = autoPotionsConfig.getInt("AutoHpPercentage", 70); AUTO_MP_PERCENTAGE = autoPotionsConfig.getInt("AutoMpPercentage", 70); - AUTO_CP_ITEM_IDS = new ArrayList<>(); + AUTO_CP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoCpItemIds", "0").split(",")) { AUTO_CP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_HP_ITEM_IDS = new ArrayList<>(); + AUTO_HP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoHpItemIds", "0").split(",")) { AUTO_HP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_MP_ITEM_IDS = new ArrayList<>(); + AUTO_MP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoMpItemIds", "0").split(",")) { AUTO_MP_ITEM_IDS.add(Integer.parseInt(s)); @@ -3172,7 +3172,7 @@ public class Config COMMUNITY_PREMIUM_COIN_ID = communityBoardConfig.getInt("CommunityPremiumBuyCoinId", 57); COMMUNITY_PREMIUM_PRICE_PER_DAY = communityBoardConfig.getInt("CommunityPremiumPricePerDay", 1000000); final String[] allowedBuffs = communityBoardConfig.getString("CommunityAvailableBuffs", "").split(","); - COMMUNITY_AVAILABLE_BUFFS = new ArrayList<>(allowedBuffs.length); + COMMUNITY_AVAILABLE_BUFFS = new HashSet<>(allowedBuffs.length); for (String s : allowedBuffs) { COMMUNITY_AVAILABLE_BUFFS.add(Integer.parseInt(s)); @@ -3479,7 +3479,7 @@ public class Config if (ENABLE_RANDOM_MONSTER_SPAWNS) { final String[] mobsIds = randomSpawnsConfig.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); - MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + MOBS_LIST_NOT_RANDOM = new HashSet<>(mobsIds.length); for (String id : mobsIds) { MOBS_LIST_NOT_RANDOM.add(Integer.parseInt(id)); diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java index d6e0183c6f..c3977185b4 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java @@ -202,8 +202,7 @@ public class ClanHallData implements IXmlReader final Door door = DoorData.getInstance().getDoor(doorId); for (ClanHall ch : _clanHalls.values()) { - final List doors = ch.getDoors(); - if ((doors != null) && doors.contains(door)) + if (ch.getDoors().contains(door)) { return ch; } diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java index 6aa0a1fdde..fb395b9e2d 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java @@ -17,10 +17,10 @@ package org.l2jmobius.gameserver.data.xml; import java.io.File; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -42,7 +42,7 @@ public class FakePlayerData implements IXmlReader private final Map _fakePlayerInfos = new HashMap<>(); private final Map _fakePlayerNames = new HashMap<>(); private final Map _fakePlayerIds = new HashMap<>(); - private final List _talkableFakePlayerNames = new ArrayList<>(); + private final Set _talkableFakePlayerNames = new HashSet<>(); protected FakePlayerData() { diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java index d335b95954..1122d7b9ba 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java @@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -49,7 +51,7 @@ import org.l2jmobius.gameserver.util.Util; public class SellBuffsManager implements IXmlReader { private static final Logger LOGGER = Logger.getLogger(SellBuffsManager.class.getName()); - private static final List ALLOWED_BUFFS = new ArrayList<>(); + private static final Set ALLOWED_BUFFS = new HashSet<>(); private static final String HTML_FOLDER = "data/html/mods/SellBuffs/"; protected SellBuffsManager() @@ -76,11 +78,7 @@ public class SellBuffsManager implements IXmlReader { final Element elem = (Element) node.item(i); final int skillId = Integer.parseInt(elem.getAttribute("id")); - - if (!ALLOWED_BUFFS.contains(skillId)) - { - ALLOWED_BUFFS.add(skillId); - } + ALLOWED_BUFFS.add(skillId); } } diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java index b10f75ef3d..1e45a21319 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java @@ -19,8 +19,10 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; @@ -67,7 +69,7 @@ public class WalkingManager implements IXmlReader public static final byte REPEAT_TELE_FIRST = 2; public static final byte REPEAT_RANDOM = 3; - private final List _targetedNpcIds = new ArrayList<>(); + private final Set _targetedNpcIds = new HashSet<>(); private final Map _routes = new HashMap<>(); // all available routes private final Map _activeRoutes = new HashMap<>(); // each record represents NPC, moving by predefined route from _routes, and moving progress private final Map _routesToAttach = new HashMap<>(); // each record represents NPC and all available routes for it diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/BlockList.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/BlockList.java index 1af9941ed5..9ac6266e22 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/BlockList.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/BlockList.java @@ -19,9 +19,9 @@ package org.l2jmobius.gameserver.model; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -36,10 +36,11 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; public class BlockList { private static final Logger LOGGER = Logger.getLogger(BlockList.class.getName()); - private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); + + private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); private final Player _owner; - private List _blockList; + private Set _blockList; public BlockList(Player owner) { @@ -68,9 +69,9 @@ public class BlockList OFFLINE_LIST.put(_owner.getObjectId(), _blockList); } - private static List loadList(int objId) + private static Set loadList(int objId) { - final List list = new ArrayList<>(); + final Set list = new HashSet<>(); try (Connection con = DatabaseFactory.getConnection(); PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1")) { @@ -158,7 +159,7 @@ public class BlockList _owner.setMessageRefusal(value); } - private List getBlockList() + private Set getBlockList() { return _blockList; } diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/PetData.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/PetData.java index b534c21f36..231b85e85f 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/PetData.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/PetData.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; import org.l2jmobius.gameserver.model.holders.SkillHolder; @@ -40,7 +42,7 @@ public class PetData private int _minLevel = Byte.MAX_VALUE; private int _maxLevel = 0; private boolean _syncLevel = false; - private final List _food = new ArrayList<>(); + private final Set _food = new HashSet<>(); public PetData(int npcId, int itemId) { @@ -133,7 +135,7 @@ public class PetData /** * @return the pet's food list. */ - public List getFood() + public Set getFood() { return _food; } diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/SkillLearn.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/SkillLearn.java index a69d30f105..3d5704b5f2 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/SkillLearn.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/SkillLearn.java @@ -16,9 +16,8 @@ */ package org.l2jmobius.gameserver.model; -import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashSet; -import java.util.List; import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -40,12 +39,12 @@ public class SkillLearn private final int _getDualClassLevel; private final boolean _autoGet; private final long _levelUpSp; - private final List _requiredItems = new ArrayList<>(); - private final List _races = new ArrayList<>(); - private final List _preReqSkills = new ArrayList<>(); + private final Set _requiredItems = new HashSet<>(1); + private final Set _races = EnumSet.noneOf(Race.class); + private final Set _preReqSkills = new HashSet<>(1); private SocialClass _socialClass; private final boolean _residenceSkill; - private final List _residenceIds = new ArrayList<>(); + private final Set _residenceIds = new HashSet<>(1); private final boolean _learnedByNpc; private final boolean _learnedByFS; private final Set _removeSkills = new HashSet<>(1); @@ -133,9 +132,9 @@ public class SkillLearn } /** - * @return the list with the item holders required to acquire this skill. + * @return the set with the item holders required to acquire this skill. */ - public List getRequiredItems() + public Set getRequiredItems() { return _requiredItems; } @@ -150,9 +149,9 @@ public class SkillLearn } /** - * @return a list with the races that can acquire this skill. + * @return a set with the races that can acquire this skill. */ - public List getRaces() + public Set getRaces() { return _races; } @@ -167,9 +166,9 @@ public class SkillLearn } /** - * @return the list of skill holders required to acquire this skill. + * @return the set of skill holders required to acquire this skill. */ - public List getPreReqSkills() + public Set getPreReqSkills() { return _preReqSkills; } @@ -212,9 +211,9 @@ public class SkillLearn } /** - * @return a list with the Ids where this skill is available. + * @return a set with the Ids where this skill is available. */ - public List getResidenceIds() + public Set getResidenceIds() { return _residenceIds; } diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java index d80071ca22..b088c8b8c9 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java @@ -22,7 +22,6 @@ import java.sql.ResultSet; import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.List; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; @@ -153,7 +152,7 @@ public class Pet extends Summon broadcastStatusUpdate(); - final List foodIds = getPetData().getFood(); + final Set foodIds = getPetData().getFood(); if (foodIds.isEmpty()) { if (isUncontrollable()) diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java index 11efe435d8..1ed0ee81a4 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java @@ -16,8 +16,8 @@ */ package org.l2jmobius.gameserver.model.actor.instance; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import org.l2jmobius.commons.threads.ThreadPool; @@ -57,7 +57,7 @@ public class Trap extends Npc private boolean _isTriggered; private final int _lifeTime; private Player _owner; - private final List _playersWhoDetectedMe = new ArrayList<>(); + private final Set _playersWhoDetectedMe = new HashSet<>(); private final SkillHolder _skill; private int _remainingTime; // Tasks diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java index 71ef076212..3ba8c20a9b 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor.tasks.player; -import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -69,11 +69,12 @@ public class PetFeedTask implements Runnable _player.sendPacket(SystemMessageId.YOU_ARE_OUT_OF_FEED_MOUNT_STATUS_CANCELED); } - final List foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); + final Set foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); if (foodIds.isEmpty()) { return; } + Item food = null; for (int id : foodIds) { diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java index 50d2a821c3..2611b5f121 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.actor.Creature; @@ -29,9 +29,9 @@ import org.l2jmobius.gameserver.model.zone.ZoneType; */ public class ConditionPlayerInsideZoneId extends Condition { - private final List _zones; + private final Set _zones; - public ConditionPlayerInsideZoneId(List zones) + public ConditionPlayerInsideZoneId(Set zones) { _zones = zones; } diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java index c15065eca2..d644f663f5 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Player; @@ -29,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerInstanceId extends Condition { - private final List _instanceIds; + private final Set _instanceIds; /** * Instantiates a new condition player instance id. * @param instanceIds the instance ids */ - public ConditionPlayerInstanceId(List instanceIds) + public ConditionPlayerInstanceId(Set instanceIds) { _instanceIds = instanceIds; } diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java index 14d61089ed..7c375ec45e 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -28,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerRace extends Condition { - private final Race[] _races; + private final Set _races; /** * Instantiates a new condition player race. * @param races the list containing the allowed races. */ - public ConditionPlayerRace(Race[] races) + public ConditionPlayerRace(Set races) { _races = races; } @@ -46,6 +47,6 @@ public class ConditionPlayerRace extends Condition { return false; } - return CommonUtil.contains(_races, effector.getActingPlayer().getRace()); + return _races.contains(effector.getActingPlayer().getRace()); } } diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java index 0f54766571..0b326e3f40 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId())) + if (_npcIds.contains(target.getId())) { existNpc = true; break; diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java index c5c9b5ff0e..db64b6bd7b 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromSummonedNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromSummonedNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromSummonedNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromSummonedNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId()) && (effector == target.getSummoner())) + if (_npcIds.contains(target.getId()) && (effector == target.getSummoner())) { existNpc = true; break; diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java index a3fb0f5374..a47b4b4983 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetClassIdRestriction extends Condition { - private final List _classIds; + private final Set _classIds; /** * Instantiates a new condition target class id restriction. * @param classId the class id */ - public ConditionTargetClassIdRestriction(List classId) + public ConditionTargetClassIdRestriction(Set classId) { _classIds = classId; } diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java index 82b1bd5877..9bb694f4ef 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetNpcId extends Condition { - private final List _npcIds; + private final Set _npcIds; /** * Instantiates a new condition target npc id. * @param npcIds the npc ids */ - public ConditionTargetNpcId(List npcIds) + public ConditionTargetNpcId(Set npcIds) { _npcIds = npcIds; } diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java index f26329bc21..5c86f26ae5 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.holders; -import java.util.Collection; +import java.util.Set; /** * @author Mobius @@ -25,9 +25,9 @@ public class EventDropHolder extends DropHolder { private final int _minLevel; private final int _maxLevel; - private final Collection _monsterIds; + private final Set _monsterIds; - public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Collection monsterIds) + public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Set monsterIds) { super(null, itemId, min, max, chance); _minLevel = minLevel; @@ -45,7 +45,7 @@ public class EventDropHolder extends DropHolder return _maxLevel; } - public Collection getMonsterIds() + public Set getMonsterIds() { return _monsterIds; } diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/item/Henna.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/item/Henna.java index af805ac1bc..6c2c9feea3 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/item/Henna.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/item/Henna.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model.item; import java.util.ArrayList; import java.util.EnumMap; +import java.util.EnumSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.enums.ClassId; import org.l2jmobius.gameserver.model.StatSet; @@ -42,7 +44,7 @@ public class Henna private final int _cancelCount; private final int _duration; private final List _skills; - private final List _wearClass; + private final Set _wearClass; public Henna(StatSet set) { @@ -63,7 +65,7 @@ public class Henna _cancelCount = set.getInt("cancel_count"); _duration = set.getInt("duration", -1); _skills = new ArrayList<>(); - _wearClass = new ArrayList<>(); + _wearClass = EnumSet.noneOf(ClassId.class); } /** @@ -159,7 +161,7 @@ public class Henna /** * @return the list with the allowed classes to wear this dye. */ - public List getAllowedWearClass() + public Set getAllowedWearClass() { return _wearClass; } diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java index 18d7b61ca2..65402c4c89 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java @@ -17,9 +17,10 @@ package org.l2jmobius.gameserver.model.item.appearance; import java.time.Duration; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.enums.Race; @@ -47,12 +48,12 @@ public class AppearanceStone private final ArmorType _armorType; private final AppearanceHandType _handType; private final AppearanceMagicType _magicType; - private List _crystalTypes; - private List _targetTypes; - private List _bodyParts; - private List _races; - private List _racesNot; - private List _allVisualIds; + private Set _crystalTypes; + private Set _targetTypes; + private Set _bodyParts; + private Set _races; + private Set _racesNot; + private Set _allVisualIds; public AppearanceStone(StatSet set) { @@ -172,35 +173,35 @@ public class AppearanceStone { if (_crystalTypes == null) { - _crystalTypes = new ArrayList<>(); + _crystalTypes = EnumSet.noneOf(CrystalType.class); } _crystalTypes.add(type); } - public List getCrystalTypes() + public Set getCrystalTypes() { - return _crystalTypes != null ? _crystalTypes : Collections.emptyList(); + return _crystalTypes != null ? _crystalTypes : Collections.emptySet(); } public void addTargetType(AppearanceTargetType type) { if (_targetTypes == null) { - _targetTypes = new ArrayList<>(); + _targetTypes = EnumSet.noneOf(AppearanceTargetType.class); } _targetTypes.add(type); } - public List getTargetTypes() + public Set getTargetTypes() { - return _targetTypes != null ? _targetTypes : Collections.emptyList(); + return _targetTypes != null ? _targetTypes : Collections.emptySet(); } public void addBodyPart(Integer part) { if (_bodyParts == null) { - _bodyParts = new ArrayList<>(); + _bodyParts = new HashSet<>(); } _bodyParts.add(part); } @@ -209,47 +210,47 @@ public class AppearanceStone { if (_allVisualIds == null) { - _allVisualIds = new ArrayList<>(); + _allVisualIds = new HashSet<>(); } _allVisualIds.add(appearanceHolder); } - public List getVisualIds() + public Set getVisualIds() { - return _allVisualIds != null ? _allVisualIds : Collections.emptyList(); + return _allVisualIds != null ? _allVisualIds : Collections.emptySet(); } - public List getBodyParts() + public Set getBodyParts() { - return _bodyParts != null ? _bodyParts : Collections.emptyList(); + return _bodyParts != null ? _bodyParts : Collections.emptySet(); } public void addRace(Race race) { if (_races == null) { - _races = new ArrayList<>(); + _races = EnumSet.noneOf(Race.class); } _races.add(race); } - public List getRaces() + public Set getRaces() { - return _races != null ? _races : Collections.emptyList(); + return _races != null ? _races : Collections.emptySet(); } public void addRaceNot(Race race) { if (_racesNot == null) { - _racesNot = new ArrayList<>(); + _racesNot = EnumSet.noneOf(Race.class); } _racesNot.add(race); } - public List getRacesNot() + public Set getRacesNot() { - return _racesNot != null ? _racesNot : Collections.emptyList(); + return _racesNot != null ? _racesNot : Collections.emptySet(); } /** @@ -302,7 +303,7 @@ public class AppearanceStone { // Seems like in retail item with already changed appearance, can be changed again without being restored. - final AppearanceTargetType targetType = getTargetTypes().get(0); + final AppearanceTargetType targetType = getTargetTypes().stream().findFirst().get(); switch (targetType) { case NONE: diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java index c21f776020..9af155da21 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java @@ -16,16 +16,16 @@ */ package org.l2jmobius.gameserver.model.item.enchant; +import java.util.EnumSet; +import java.util.Set; import java.util.logging.Logger; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.item.ItemTemplate; import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.model.item.type.CrystalType; import org.l2jmobius.gameserver.model.item.type.EtcItemType; -import org.l2jmobius.gameserver.model.item.type.ItemType; /** * @author UnAfraid @@ -34,28 +34,29 @@ public abstract class AbstractEnchantItem { protected static final Logger LOGGER = Logger.getLogger(AbstractEnchantItem.class.getName()); - private static final ItemType[] ENCHANT_TYPES = new ItemType[] + private static final Set ENCHANT_TYPES = EnumSet.noneOf(EtcItemType.class); + static { - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM, - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP, - EtcItemType.BLESS_ENCHT_AM, - EtcItemType.BLESS_ENCHT_AM_DOWN, - EtcItemType.BLESS_ENCHT_WP, - EtcItemType.ENCHT_AM, - EtcItemType.ENCHT_WP, - EtcItemType.ENCHT_WP_DOWN, - EtcItemType.ENCHT_AM_DOWN, - EtcItemType.GIANT_ENCHT_AM, - EtcItemType.GIANT_ENCHT_WP, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - }; + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP_DOWN); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + } private final int _id; private final CrystalType _grade; @@ -73,7 +74,7 @@ public abstract class AbstractEnchantItem { throw new NullPointerException(); } - else if (!CommonUtil.contains(ENCHANT_TYPES, getItem().getItemType())) + else if (!ENCHANT_TYPES.contains(getItem().getItemType())) { throw new IllegalAccessError(); } diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java index 5ba6755084..18508d0145 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java @@ -24,8 +24,10 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Set; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -184,7 +186,7 @@ public class LongTimeEvent extends Quest final Node maxLevelNode = d.getAttributes().getNamedItem("maxLevel"); final int maxLevel = maxLevelNode == null ? Integer.MAX_VALUE : Integer.parseInt(maxLevelNode.getNodeValue()); final Node monsterIdsNode = d.getAttributes().getNamedItem("monsterIds"); - final List monsterIds = new ArrayList<>(); + final Set monsterIds = new HashSet<>(); if (monsterIdsNode != null) { for (String id : monsterIdsNode.getNodeValue().split(",")) diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/residences/ClanHall.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/residences/ClanHall.java index 0c0a529077..fcc850371b 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/residences/ClanHall.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/residences/ClanHall.java @@ -23,7 +23,9 @@ import java.sql.SQLException; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -61,9 +63,9 @@ public class ClanHall extends AbstractResidence private final int _minBid; final int _lease; private final int _deposit; - private final List _npcs; - private final List _doors; - private final List _teleports; + private final Set _npcs = new HashSet<>(); + private final Set _doors = new HashSet<>(); + private final Set _teleports = new HashSet<>(); private final Location _ownerLocation; private final Location _banishLocation; // Dynamic parameters @@ -85,9 +87,21 @@ public class ClanHall extends AbstractResidence _minBid = params.getInt("minBid"); _lease = params.getInt("lease"); _deposit = params.getInt("deposit"); - _npcs = params.getList("npcList", Integer.class); - _doors = params.getList("doorList", Door.class); - _teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + final List npcs = params.getList("npcList", Integer.class); + if (npcs != null) + { + _npcs.addAll(npcs); + } + final List doors = params.getList("doorList", Door.class); + if (doors != null) + { + _doors.addAll(doors); + } + final List teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + if (teleports != null) + { + _teleports.addAll(teleports); + } _ownerLocation = params.getLocation("owner_loc"); _banishLocation = params.getLocation("banish_loc"); // Set dynamic parameters (from DB) @@ -196,7 +210,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Door} related to this {@link ClanHall}. * @return all {@link Door} related to this {@link ClanHall} */ - public List getDoors() + public Set getDoors() { return _doors; } @@ -205,7 +219,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Npc} related to this {@link ClanHall}. * @return all {@link Npc} related to this {@link ClanHall} */ - public List getNpcs() + public Set getNpcs() { return _npcs; } @@ -324,7 +338,7 @@ public class ClanHall extends AbstractResidence return _banishLocation; } - public List getTeleportList() + public Set getTeleportList() { return _teleports; } diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/siege/Castle.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/siege/Castle.java index 9f883b28a1..30a0c5b33b 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/siege/Castle.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/siege/Castle.java @@ -21,8 +21,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.Calendar; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -82,7 +84,7 @@ public class Castle extends AbstractResidence private SiegeZone _zone = null; private ResidenceTeleportZone _teleZone; private Clan _formerOwner = null; - private final List _artefacts = new ArrayList<>(1); + private final Set _artefacts = new HashSet<>(1); private final Map _function = new ConcurrentHashMap<>(); private int _ticketBuyCount = 0; private boolean _isFirstMidVictory = false; @@ -1071,7 +1073,7 @@ public class Castle extends AbstractResidence _artefacts.add(artefact); } - public List getArtefacts() + public Set getArtefacts() { return _artefacts; } diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java index 0c79677eae..4ebf954ee5 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.network.serverpackets; -import java.util.List; +import java.util.Set; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.gameserver.data.sql.CharNameTable; @@ -27,19 +27,19 @@ import org.l2jmobius.gameserver.network.OutgoingPackets; */ public class BlockListPacket implements IClientOutgoingPacket { - private final List _playersId; + private final Set _playerIds; - public BlockListPacket(List playersId) + public BlockListPacket(Set playerIds) { - _playersId = playersId; + _playerIds = playerIds; } @Override public boolean write(PacketWriter packet) { OutgoingPackets.BLOCK_LIST.writeId(packet); - packet.writeD(_playersId.size()); - for (int playerId : _playersId) + packet.writeD(_playerIds.size()); + for (int playerId : _playerIds) { packet.writeS(CharNameTable.getInstance().getNameById(playerId)); packet.writeS(""); // memo ? diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java index 8555bb6e86..eb5bfd05d8 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.network.serverpackets; import java.util.List; import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; import org.l2jmobius.commons.network.PacketWriter; @@ -37,7 +38,7 @@ public class ExAcquireSkillInfo implements IClientOutgoingPacket private final int _dualClassLevel; private final long _spCost; private final int _minLevel; - private final List _itemReq; + private final Set _itemReq; private final List _skillRem; /** diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java index 84b5fead76..a163a85735 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java @@ -35,7 +35,7 @@ public class ExChooseShapeShiftingItem implements IClientOutgoingPacket public ExChooseShapeShiftingItem(AppearanceStone stone) { _type = stone.getType(); - _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().get(0); + _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().stream().findFirst().get(); _itemId = stone.getId(); } diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/util/DocumentBase.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/util/DocumentBase.java index 8a8e13d940..c22140b9c4 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/util/DocumentBase.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/util/DocumentBase.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.util; import java.io.File; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -390,12 +391,12 @@ public abstract class DocumentBase case "races": { final String[] racesVal = a.getNodeValue().split(","); - final Race[] races = new Race[racesVal.length]; + final Set races = EnumSet.noneOf(Race.class); for (int r = 0; r < racesVal.length; r++) { if (racesVal[r] != null) { - races[r] = Race.valueOf(racesVal[r]); + races.add(Race.valueOf(racesVal[r])); } } cond = joinAnd(cond, new ConditionPlayerRace(races)); @@ -671,13 +672,13 @@ public abstract class DocumentBase case "instanceid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final ArrayList array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInstanceId(array)); + cond = joinAnd(cond, new ConditionPlayerInstanceId(set)); break; } case "agathionid": @@ -728,10 +729,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -745,10 +746,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -834,13 +835,13 @@ public abstract class DocumentBase case "insidezoneid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInsideZoneId(array)); + cond = joinAnd(cond, new ConditionPlayerInsideZoneId(set)); break; } case "checkabnormal": @@ -961,13 +962,13 @@ public abstract class DocumentBase case "class_id_restriction": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetClassIdRestriction(array)); + cond = joinAnd(cond, new ConditionTargetClassIdRestriction(set)); break; } case "active_effect_id": @@ -1045,13 +1046,13 @@ public abstract class DocumentBase case "npcid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetNpcId(array)); + cond = joinAnd(cond, new ConditionTargetNpcId(set)); break; } case "npctype": diff --git a/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/handlers/bypasshandlers/Link.java b/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/handlers/bypasshandlers/Link.java index 5bd82b732d..360ed1ae88 100644 --- a/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/handlers/bypasshandlers/Link.java +++ b/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/handlers/bypasshandlers/Link.java @@ -16,7 +16,9 @@ */ package handlers.bypasshandlers; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.HashSet; +import java.util.Set; + import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.handler.IBypassHandler; import org.l2jmobius.gameserver.model.actor.Creature; @@ -31,67 +33,68 @@ public class Link implements IBypassHandler "Link" }; - private static final String[] VALID_LINKS = + private static final Set VALID_LINKS = new HashSet<>(); + static { - "common/attribute_info.htm", - "common/augmentation_01.htm", - "common/augmentation_02.htm", - "common/augmentation_exchange.htm", - "common/crafting_01.htm", - "common/crafting_02.htm", - "common/crafting_03.htm", - "common/cursed_to_unidentified.htm", - "common/duals_01.htm", - "common/duals_02.htm", - "common/duals_03.htm", - "common/g_cube_warehouse001.htm", - "common/skill_enchant_help.htm", - "common/skill_enchant_help_01.htm", - "common/skill_enchant_help_02.htm", - "common/skill_enchant_help_03.htm", - "common/smelting_trade001.htm", - "common/weapon_sa_01.htm", - "common/welcomeback002.htm", - "common/welcomeback003.htm", - "default/BlessingOfProtection.htm", - "default/SupportMagic.htm", - "default/SupportMagicServitor.htm", - "fisherman/exchange_old_items.htm", - "fisherman/fish_appearance_exchange.htm", - "fisherman/fishing_manual001.htm", - "fisherman/fishing_manual002.htm", - "fisherman/fishing_manual003.htm", - "fisherman/fishing_manual004.htm", - "fisherman/fishing_manual008.htm", - "fisherman/fishing_manual009.htm", - "fisherman/fishing_manual010.htm", - "fortress/foreman.htm", - "guard/kamaloka_help.htm", - "guard/kamaloka_level.htm", - "petmanager/evolve.htm", - "petmanager/exchange.htm", - "petmanager/instructions.htm", - "teleporter/separatedsoul.htm", - "warehouse/clanwh.htm", - "warehouse/privatewh.htm", + VALID_LINKS.add("common/attribute_info.htm"); + VALID_LINKS.add("common/augmentation_01.htm"); + VALID_LINKS.add("common/augmentation_02.htm"); + VALID_LINKS.add("common/augmentation_exchange.htm"); + VALID_LINKS.add("common/crafting_01.htm"); + VALID_LINKS.add("common/crafting_02.htm"); + VALID_LINKS.add("common/crafting_03.htm"); + VALID_LINKS.add("common/cursed_to_unidentified.htm"); + VALID_LINKS.add("common/duals_01.htm"); + VALID_LINKS.add("common/duals_02.htm"); + VALID_LINKS.add("common/duals_03.htm"); + VALID_LINKS.add("common/g_cube_warehouse001.htm"); + VALID_LINKS.add("common/skill_enchant_help.htm"); + VALID_LINKS.add("common/skill_enchant_help_01.htm"); + VALID_LINKS.add("common/skill_enchant_help_02.htm"); + VALID_LINKS.add("common/skill_enchant_help_03.htm"); + VALID_LINKS.add("common/smelting_trade001.htm"); + VALID_LINKS.add("common/weapon_sa_01.htm"); + VALID_LINKS.add("common/welcomeback002.htm"); + VALID_LINKS.add("common/welcomeback003.htm"); + VALID_LINKS.add("default/BlessingOfProtection.htm"); + VALID_LINKS.add("default/SupportMagic.htm"); + VALID_LINKS.add("default/SupportMagicServitor.htm"); + VALID_LINKS.add("fisherman/exchange_old_items.htm"); + VALID_LINKS.add("fisherman/fish_appearance_exchange.htm"); + VALID_LINKS.add("fisherman/fishing_manual001.htm"); + VALID_LINKS.add("fisherman/fishing_manual002.htm"); + VALID_LINKS.add("fisherman/fishing_manual003.htm"); + VALID_LINKS.add("fisherman/fishing_manual004.htm"); + VALID_LINKS.add("fisherman/fishing_manual008.htm"); + VALID_LINKS.add("fisherman/fishing_manual009.htm"); + VALID_LINKS.add("fisherman/fishing_manual010.htm"); + VALID_LINKS.add("fortress/foreman.htm"); + VALID_LINKS.add("guard/kamaloka_help.htm"); + VALID_LINKS.add("guard/kamaloka_level.htm"); + VALID_LINKS.add("petmanager/evolve.htm"); + VALID_LINKS.add("petmanager/exchange.htm"); + VALID_LINKS.add("petmanager/instructions.htm"); + VALID_LINKS.add("teleporter/separatedsoul.htm"); + VALID_LINKS.add("warehouse/clanwh.htm"); + VALID_LINKS.add("warehouse/privatewh.htm"); // Quests - "teleporter/30006.htm", - "teleporter/30006-Q561.htm", - "teleporter/30006-Q561-1.htm", - "teleporter/30006-Q561-2.htm", - "teleporter/30134.htm", - "teleporter/30134-Q562.htm", - "teleporter/30134-Q562-1.htm", - "teleporter/30134-Q562-2.htm", - "teleporter/30256.htm", - "teleporter/30256-Q562.htm", - "teleporter/30256-Q562-1.htm", - "teleporter/30256-Q562-2.htm", - "teleporter/30848.htm", - "teleporter/30848-Q561-Q562.htm", - "teleporter/30848-Q561-Q562-1.htm", - "teleporter/30848-Q561-Q562-2.htm", - }; + VALID_LINKS.add("teleporter/30006.htm"); + VALID_LINKS.add("teleporter/30006-Q561.htm"); + VALID_LINKS.add("teleporter/30006-Q561-1.htm"); + VALID_LINKS.add("teleporter/30006-Q561-2.htm"); + VALID_LINKS.add("teleporter/30134.htm"); + VALID_LINKS.add("teleporter/30134-Q562.htm"); + VALID_LINKS.add("teleporter/30134-Q562-1.htm"); + VALID_LINKS.add("teleporter/30134-Q562-2.htm"); + VALID_LINKS.add("teleporter/30256.htm"); + VALID_LINKS.add("teleporter/30256-Q562.htm"); + VALID_LINKS.add("teleporter/30256-Q562-1.htm"); + VALID_LINKS.add("teleporter/30256-Q562-2.htm"); + VALID_LINKS.add("teleporter/30848.htm"); + VALID_LINKS.add("teleporter/30848-Q561-Q562.htm"); + VALID_LINKS.add("teleporter/30848-Q561-Q562-1.htm"); + VALID_LINKS.add("teleporter/30848-Q561-Q562-2.htm"); + } @Override public boolean useBypass(String command, Player player, Creature target) @@ -109,12 +112,13 @@ public class Link implements IBypassHandler return false; } - String content = CommonUtil.contains(VALID_LINKS, htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; + String content = VALID_LINKS.contains(htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; // Precaution. if (htmlPath.startsWith("teleporter/") && !(player.getTarget() instanceof Teleporter)) { content = null; } + final NpcHtmlMessage html = new NpcHtmlMessage(target != null ? target.getObjectId() : 0); if (content != null) { diff --git a/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/handlers/itemhandlers/PetFood.java b/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/handlers/itemhandlers/PetFood.java index 3c5572d4ec..8b908ea095 100644 --- a/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/handlers/itemhandlers/PetFood.java +++ b/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/handlers/itemhandlers/PetFood.java @@ -17,6 +17,7 @@ package handlers.itemhandlers; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.PetDataTable; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -79,7 +80,7 @@ public class PetFood implements IItemHandler final Player player = activeChar.getActingPlayer(); if (player.isMounted()) { - final List foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); + final Set foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); if (foodIds.contains(item.getId()) && player.destroyItem("Consume", item.getObjectId(), 1, null, false)) { player.broadcastPacket(new MagicSkillUse(player, player, skillId, skillLevel, 0, 0)); diff --git a/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java b/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java index 2ad282f683..99f45fbb41 100644 --- a/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java +++ b/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.ClanHallData; import org.l2jmobius.gameserver.model.StatSet; @@ -32,12 +33,12 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpCheckResidenceSkillCondition implements ISkillCondition { - private final List _residencesId; + private final Set _residencesId = new HashSet<>(); private final boolean _isWithin; public OpCheckResidenceSkillCondition(StatSet params) { - _residencesId = params.getList("residencesId", Integer.class); + _residencesId.addAll(params.getList("residencesId", Integer.class)); _isWithin = params.getBoolean("isWithin"); } diff --git a/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java b/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java index fc2934423b..4a8282d988 100644 --- a/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java +++ b/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java @@ -16,9 +16,9 @@ */ package handlers.skillconditionhandlers; -import java.util.ArrayList; -import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -28,18 +28,18 @@ import org.l2jmobius.gameserver.model.skill.ISkillCondition; import org.l2jmobius.gameserver.model.skill.Skill; /** - * @author UnAfraid + * @author UnAfraid, Mobius */ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition { - private final List _npcIds = new ArrayList<>(); + private final Set _npcIds = new HashSet<>(); public OpNeedSummonOrPetSkillCondition(StatSet params) { - final List npcIds = params.getList("npcIds", String.class); + final List npcIds = params.getList("npcIds", Integer.class); if (npcIds != null) { - npcIds.stream().map(Integer::valueOf).forEach(_npcIds::add); + _npcIds.addAll(npcIds); } } @@ -47,7 +47,19 @@ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition public boolean canUse(Creature caster, Skill skill, WorldObject target) { final Summon pet = caster.getPet(); - final Collection summons = caster.getServitors().values(); - return ((pet != null) && _npcIds.stream().anyMatch(npcId -> npcId == pet.getId())) || summons.stream().anyMatch(summon -> _npcIds.contains(summon.getId())); + if ((pet != null) && _npcIds.contains(pet.getId())) + { + return true; + } + + for (Summon summon : caster.getServitors().values()) + { + if (_npcIds.contains(summon.getId())) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java b/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java index 8541bc62b4..ef81b291d4 100644 --- a/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java +++ b/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,11 +30,11 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetDoorSkillCondition implements ISkillCondition { - private final List _doorIds; + private final Set _doorIds = new HashSet<>(); public OpTargetDoorSkillCondition(StatSet params) { - _doorIds = params.getList("doorIds", Integer.class); + _doorIds.addAll(params.getList("doorIds", Integer.class)); } @Override diff --git a/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java b/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java index 3ce4145703..0ccd571e19 100644 --- a/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java +++ b/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,17 +30,17 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetNpcSkillCondition implements ISkillCondition { - private final List _npcId; + private final Set _npcIds = new HashSet<>(); public OpTargetNpcSkillCondition(StatSet params) { - _npcId = params.getList("npcIds", Integer.class); + _npcIds.addAll(params.getList("npcIds", Integer.class)); } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget(); - return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId()); + return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcIds.contains(actualTarget.getId()); } } diff --git a/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/instances/AbstractInstance.java b/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/instances/AbstractInstance.java index 94c337f0df..a5b4ef238a 100644 --- a/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/instances/AbstractInstance.java +++ b/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/instances/AbstractInstance.java @@ -16,9 +16,10 @@ */ package instances; +import java.util.HashSet; import java.util.List; +import java.util.Set; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.enums.InstanceReenterType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.instancemanager.InstanceManager; @@ -40,25 +41,29 @@ import ai.AbstractNpcAI; */ public abstract class AbstractInstance extends AbstractNpcAI { - private final int[] _templateIds; + private final Set _templateIds = new HashSet<>(); - public AbstractInstance(int... templateId) + public AbstractInstance(int... templateIds) { - if (templateId.length == 0) + if (templateIds.length == 0) { throw new IllegalStateException("No template ids were provided!"); } - _templateIds = templateId; + + for (int templateId : templateIds) + { + _templateIds.add(templateId); + } } - public int[] getTemplateId() + public Set getTemplateId() { return _templateIds; } public boolean isInInstance(Instance instance) { - return (instance != null) && CommonUtil.contains(_templateIds, instance.getTemplateId()); + return (instance != null) && _templateIds.contains(instance.getTemplateId()); } /** diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/Config.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/Config.java index af85fae12c..8f004e5965 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/Config.java @@ -286,7 +286,7 @@ public class Config public static boolean AUTO_LOOT_SLOT_LIMIT; public static int LOOT_RAIDS_PRIVILEGE_INTERVAL; public static int LOOT_RAIDS_PRIVILEGE_CC_SIZE; - public static List AUTO_LOOT_ITEM_IDS; + public static Set AUTO_LOOT_ITEM_IDS; public static boolean ENABLE_KEYBOARD_MOVEMENT; public static int UNSTUCK_INTERVAL; public static int TELEPORT_WATCHDOG_TIMEOUT; @@ -454,7 +454,7 @@ public class Config public static boolean ALLOW_DISCARDITEM; public static int AUTODESTROY_ITEM_AFTER; public static int HERB_AUTO_DESTROY_TIME; - public static List LIST_PROTECTED_ITEMS; + public static Set LIST_PROTECTED_ITEMS; public static boolean DATABASE_CLEAN_UP; public static int CHAR_DATA_STORE_INTERVAL; public static int CLAN_VARIABLES_STORE_INTERVAL; @@ -547,7 +547,7 @@ public class Config public static boolean ALT_OLY_LOG_FIGHTS; public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS; public static boolean ALT_OLY_ANNOUNCE_GAMES; - public static List LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(); + public static Set LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(); public static int ALT_OLY_WEAPON_ENCHANT_LIMIT; public static int ALT_OLY_ARMOR_ENCHANT_LIMIT; public static int ALT_OLY_WAIT_TIME; @@ -1205,9 +1205,9 @@ public class Config public static int AUTO_CP_PERCENTAGE; public static int AUTO_HP_PERCENTAGE; public static int AUTO_MP_PERCENTAGE; - public static List AUTO_CP_ITEM_IDS; - public static List AUTO_HP_ITEM_IDS; - public static List AUTO_MP_ITEM_IDS; + public static Set AUTO_CP_ITEM_IDS; + public static Set AUTO_HP_ITEM_IDS; + public static Set AUTO_MP_ITEM_IDS; public static boolean CUSTOM_STARTING_LOC; public static int CUSTOM_STARTING_LOC_X; public static int CUSTOM_STARTING_LOC_Y; @@ -1217,7 +1217,7 @@ public class Config public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; public static int MOB_MIN_SPAWN_RANGE; public static int MOB_MAX_SPAWN_RANGE; - public static List MOBS_LIST_NOT_RANDOM; + public static Set MOBS_LIST_NOT_RANDOM; public static boolean FREE_JUMPS_FOR_ALL; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; @@ -1236,7 +1236,7 @@ public class Config public static boolean COMMUNITY_PREMIUM_SYSTEM_ENABLED; public static int COMMUNITY_PREMIUM_COIN_ID; public static int COMMUNITY_PREMIUM_PRICE_PER_DAY; - public static List COMMUNITY_AVAILABLE_BUFFS; + public static Set COMMUNITY_AVAILABLE_BUFFS; public static Map COMMUNITY_AVAILABLE_TELEPORTS; public static boolean CUSTOM_DEPOSITABLE_ENABLED; public static boolean CUSTOM_DEPOSITABLE_QUEST_ITEMS; @@ -1891,7 +1891,7 @@ public class Config LOOT_RAIDS_PRIVILEGE_INTERVAL = characterConfig.getInt("RaidLootRightsInterval", 900) * 1000; LOOT_RAIDS_PRIVILEGE_CC_SIZE = characterConfig.getInt("RaidLootRightsCCSize", 45); final String[] autoLootItemIds = characterConfig.getString("AutoLootItemIds", "0").split(","); - AUTO_LOOT_ITEM_IDS = new ArrayList<>(autoLootItemIds.length); + AUTO_LOOT_ITEM_IDS = new HashSet<>(autoLootItemIds.length); for (String item : autoLootItemIds) { Integer itm = 0; @@ -2010,7 +2010,7 @@ public class Config AUTODESTROY_ITEM_AFTER = generalConfig.getInt("AutoDestroyDroppedItemAfter", 600); HERB_AUTO_DESTROY_TIME = generalConfig.getInt("AutoDestroyHerbTime", 60) * 1000; final String[] split = generalConfig.getString("ListOfProtectedItems", "0").split(","); - LIST_PROTECTED_ITEMS = new ArrayList<>(split.length); + LIST_PROTECTED_ITEMS = new HashSet<>(split.length); for (String id : split) { LIST_PROTECTED_ITEMS.add(Integer.parseInt(id)); @@ -2408,7 +2408,7 @@ public class Config if (!olyRestrictedItems.isEmpty()) { final String[] olyRestrictedItemsSplit = olyRestrictedItems.split(","); - LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(olyRestrictedItemsSplit.length); + LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(olyRestrictedItemsSplit.length); for (String id : olyRestrictedItemsSplit) { LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id)); @@ -2560,17 +2560,17 @@ public class Config AUTO_CP_PERCENTAGE = autoPotionsConfig.getInt("AutoCpPercentage", 70); AUTO_HP_PERCENTAGE = autoPotionsConfig.getInt("AutoHpPercentage", 70); AUTO_MP_PERCENTAGE = autoPotionsConfig.getInt("AutoMpPercentage", 70); - AUTO_CP_ITEM_IDS = new ArrayList<>(); + AUTO_CP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoCpItemIds", "0").split(",")) { AUTO_CP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_HP_ITEM_IDS = new ArrayList<>(); + AUTO_HP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoHpItemIds", "0").split(",")) { AUTO_HP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_MP_ITEM_IDS = new ArrayList<>(); + AUTO_MP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoMpItemIds", "0").split(",")) { AUTO_MP_ITEM_IDS.add(Integer.parseInt(s)); @@ -3181,7 +3181,7 @@ public class Config COMMUNITY_PREMIUM_COIN_ID = communityBoardConfig.getInt("CommunityPremiumBuyCoinId", 57); COMMUNITY_PREMIUM_PRICE_PER_DAY = communityBoardConfig.getInt("CommunityPremiumPricePerDay", 1000000); final String[] allowedBuffs = communityBoardConfig.getString("CommunityAvailableBuffs", "").split(","); - COMMUNITY_AVAILABLE_BUFFS = new ArrayList<>(allowedBuffs.length); + COMMUNITY_AVAILABLE_BUFFS = new HashSet<>(allowedBuffs.length); for (String s : allowedBuffs) { COMMUNITY_AVAILABLE_BUFFS.add(Integer.parseInt(s)); @@ -3488,7 +3488,7 @@ public class Config if (ENABLE_RANDOM_MONSTER_SPAWNS) { final String[] mobsIds = randomSpawnsConfig.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); - MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + MOBS_LIST_NOT_RANDOM = new HashSet<>(mobsIds.length); for (String id : mobsIds) { MOBS_LIST_NOT_RANDOM.add(Integer.parseInt(id)); diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java index d6e0183c6f..c3977185b4 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java @@ -202,8 +202,7 @@ public class ClanHallData implements IXmlReader final Door door = DoorData.getInstance().getDoor(doorId); for (ClanHall ch : _clanHalls.values()) { - final List doors = ch.getDoors(); - if ((doors != null) && doors.contains(door)) + if (ch.getDoors().contains(door)) { return ch; } diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java index 6aa0a1fdde..fb395b9e2d 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java @@ -17,10 +17,10 @@ package org.l2jmobius.gameserver.data.xml; import java.io.File; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -42,7 +42,7 @@ public class FakePlayerData implements IXmlReader private final Map _fakePlayerInfos = new HashMap<>(); private final Map _fakePlayerNames = new HashMap<>(); private final Map _fakePlayerIds = new HashMap<>(); - private final List _talkableFakePlayerNames = new ArrayList<>(); + private final Set _talkableFakePlayerNames = new HashSet<>(); protected FakePlayerData() { diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java index d335b95954..1122d7b9ba 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java @@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -49,7 +51,7 @@ import org.l2jmobius.gameserver.util.Util; public class SellBuffsManager implements IXmlReader { private static final Logger LOGGER = Logger.getLogger(SellBuffsManager.class.getName()); - private static final List ALLOWED_BUFFS = new ArrayList<>(); + private static final Set ALLOWED_BUFFS = new HashSet<>(); private static final String HTML_FOLDER = "data/html/mods/SellBuffs/"; protected SellBuffsManager() @@ -76,11 +78,7 @@ public class SellBuffsManager implements IXmlReader { final Element elem = (Element) node.item(i); final int skillId = Integer.parseInt(elem.getAttribute("id")); - - if (!ALLOWED_BUFFS.contains(skillId)) - { - ALLOWED_BUFFS.add(skillId); - } + ALLOWED_BUFFS.add(skillId); } } diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java index b10f75ef3d..1e45a21319 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java @@ -19,8 +19,10 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; @@ -67,7 +69,7 @@ public class WalkingManager implements IXmlReader public static final byte REPEAT_TELE_FIRST = 2; public static final byte REPEAT_RANDOM = 3; - private final List _targetedNpcIds = new ArrayList<>(); + private final Set _targetedNpcIds = new HashSet<>(); private final Map _routes = new HashMap<>(); // all available routes private final Map _activeRoutes = new HashMap<>(); // each record represents NPC, moving by predefined route from _routes, and moving progress private final Map _routesToAttach = new HashMap<>(); // each record represents NPC and all available routes for it diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/BlockList.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/BlockList.java index 1af9941ed5..9ac6266e22 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/BlockList.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/BlockList.java @@ -19,9 +19,9 @@ package org.l2jmobius.gameserver.model; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -36,10 +36,11 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; public class BlockList { private static final Logger LOGGER = Logger.getLogger(BlockList.class.getName()); - private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); + + private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); private final Player _owner; - private List _blockList; + private Set _blockList; public BlockList(Player owner) { @@ -68,9 +69,9 @@ public class BlockList OFFLINE_LIST.put(_owner.getObjectId(), _blockList); } - private static List loadList(int objId) + private static Set loadList(int objId) { - final List list = new ArrayList<>(); + final Set list = new HashSet<>(); try (Connection con = DatabaseFactory.getConnection(); PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1")) { @@ -158,7 +159,7 @@ public class BlockList _owner.setMessageRefusal(value); } - private List getBlockList() + private Set getBlockList() { return _blockList; } diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/PetData.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/PetData.java index b534c21f36..231b85e85f 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/PetData.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/PetData.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; import org.l2jmobius.gameserver.model.holders.SkillHolder; @@ -40,7 +42,7 @@ public class PetData private int _minLevel = Byte.MAX_VALUE; private int _maxLevel = 0; private boolean _syncLevel = false; - private final List _food = new ArrayList<>(); + private final Set _food = new HashSet<>(); public PetData(int npcId, int itemId) { @@ -133,7 +135,7 @@ public class PetData /** * @return the pet's food list. */ - public List getFood() + public Set getFood() { return _food; } diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/SkillLearn.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/SkillLearn.java index a69d30f105..3d5704b5f2 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/SkillLearn.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/SkillLearn.java @@ -16,9 +16,8 @@ */ package org.l2jmobius.gameserver.model; -import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashSet; -import java.util.List; import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -40,12 +39,12 @@ public class SkillLearn private final int _getDualClassLevel; private final boolean _autoGet; private final long _levelUpSp; - private final List _requiredItems = new ArrayList<>(); - private final List _races = new ArrayList<>(); - private final List _preReqSkills = new ArrayList<>(); + private final Set _requiredItems = new HashSet<>(1); + private final Set _races = EnumSet.noneOf(Race.class); + private final Set _preReqSkills = new HashSet<>(1); private SocialClass _socialClass; private final boolean _residenceSkill; - private final List _residenceIds = new ArrayList<>(); + private final Set _residenceIds = new HashSet<>(1); private final boolean _learnedByNpc; private final boolean _learnedByFS; private final Set _removeSkills = new HashSet<>(1); @@ -133,9 +132,9 @@ public class SkillLearn } /** - * @return the list with the item holders required to acquire this skill. + * @return the set with the item holders required to acquire this skill. */ - public List getRequiredItems() + public Set getRequiredItems() { return _requiredItems; } @@ -150,9 +149,9 @@ public class SkillLearn } /** - * @return a list with the races that can acquire this skill. + * @return a set with the races that can acquire this skill. */ - public List getRaces() + public Set getRaces() { return _races; } @@ -167,9 +166,9 @@ public class SkillLearn } /** - * @return the list of skill holders required to acquire this skill. + * @return the set of skill holders required to acquire this skill. */ - public List getPreReqSkills() + public Set getPreReqSkills() { return _preReqSkills; } @@ -212,9 +211,9 @@ public class SkillLearn } /** - * @return a list with the Ids where this skill is available. + * @return a set with the Ids where this skill is available. */ - public List getResidenceIds() + public Set getResidenceIds() { return _residenceIds; } diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java index a831809aef..ea779dbeeb 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java @@ -22,7 +22,6 @@ import java.sql.ResultSet; import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.List; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; @@ -153,7 +152,7 @@ public class Pet extends Summon broadcastStatusUpdate(); - final List foodIds = getPetData().getFood(); + final Set foodIds = getPetData().getFood(); if (foodIds.isEmpty()) { if (isUncontrollable()) diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java index 11efe435d8..1ed0ee81a4 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java @@ -16,8 +16,8 @@ */ package org.l2jmobius.gameserver.model.actor.instance; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import org.l2jmobius.commons.threads.ThreadPool; @@ -57,7 +57,7 @@ public class Trap extends Npc private boolean _isTriggered; private final int _lifeTime; private Player _owner; - private final List _playersWhoDetectedMe = new ArrayList<>(); + private final Set _playersWhoDetectedMe = new HashSet<>(); private final SkillHolder _skill; private int _remainingTime; // Tasks diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java index 71ef076212..3ba8c20a9b 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor.tasks.player; -import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -69,11 +69,12 @@ public class PetFeedTask implements Runnable _player.sendPacket(SystemMessageId.YOU_ARE_OUT_OF_FEED_MOUNT_STATUS_CANCELED); } - final List foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); + final Set foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); if (foodIds.isEmpty()) { return; } + Item food = null; for (int id : foodIds) { diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java index 50d2a821c3..2611b5f121 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.actor.Creature; @@ -29,9 +29,9 @@ import org.l2jmobius.gameserver.model.zone.ZoneType; */ public class ConditionPlayerInsideZoneId extends Condition { - private final List _zones; + private final Set _zones; - public ConditionPlayerInsideZoneId(List zones) + public ConditionPlayerInsideZoneId(Set zones) { _zones = zones; } diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java index c15065eca2..d644f663f5 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Player; @@ -29,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerInstanceId extends Condition { - private final List _instanceIds; + private final Set _instanceIds; /** * Instantiates a new condition player instance id. * @param instanceIds the instance ids */ - public ConditionPlayerInstanceId(List instanceIds) + public ConditionPlayerInstanceId(Set instanceIds) { _instanceIds = instanceIds; } diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java index 14d61089ed..7c375ec45e 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -28,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerRace extends Condition { - private final Race[] _races; + private final Set _races; /** * Instantiates a new condition player race. * @param races the list containing the allowed races. */ - public ConditionPlayerRace(Race[] races) + public ConditionPlayerRace(Set races) { _races = races; } @@ -46,6 +47,6 @@ public class ConditionPlayerRace extends Condition { return false; } - return CommonUtil.contains(_races, effector.getActingPlayer().getRace()); + return _races.contains(effector.getActingPlayer().getRace()); } } diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java index 0f54766571..0b326e3f40 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId())) + if (_npcIds.contains(target.getId())) { existNpc = true; break; diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java index c5c9b5ff0e..db64b6bd7b 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromSummonedNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromSummonedNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromSummonedNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromSummonedNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId()) && (effector == target.getSummoner())) + if (_npcIds.contains(target.getId()) && (effector == target.getSummoner())) { existNpc = true; break; diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java index a3fb0f5374..a47b4b4983 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetClassIdRestriction extends Condition { - private final List _classIds; + private final Set _classIds; /** * Instantiates a new condition target class id restriction. * @param classId the class id */ - public ConditionTargetClassIdRestriction(List classId) + public ConditionTargetClassIdRestriction(Set classId) { _classIds = classId; } diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java index 82b1bd5877..9bb694f4ef 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetNpcId extends Condition { - private final List _npcIds; + private final Set _npcIds; /** * Instantiates a new condition target npc id. * @param npcIds the npc ids */ - public ConditionTargetNpcId(List npcIds) + public ConditionTargetNpcId(Set npcIds) { _npcIds = npcIds; } diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java index f26329bc21..5c86f26ae5 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.holders; -import java.util.Collection; +import java.util.Set; /** * @author Mobius @@ -25,9 +25,9 @@ public class EventDropHolder extends DropHolder { private final int _minLevel; private final int _maxLevel; - private final Collection _monsterIds; + private final Set _monsterIds; - public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Collection monsterIds) + public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Set monsterIds) { super(null, itemId, min, max, chance); _minLevel = minLevel; @@ -45,7 +45,7 @@ public class EventDropHolder extends DropHolder return _maxLevel; } - public Collection getMonsterIds() + public Set getMonsterIds() { return _monsterIds; } diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/item/Henna.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/item/Henna.java index af805ac1bc..6c2c9feea3 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/item/Henna.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/item/Henna.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model.item; import java.util.ArrayList; import java.util.EnumMap; +import java.util.EnumSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.enums.ClassId; import org.l2jmobius.gameserver.model.StatSet; @@ -42,7 +44,7 @@ public class Henna private final int _cancelCount; private final int _duration; private final List _skills; - private final List _wearClass; + private final Set _wearClass; public Henna(StatSet set) { @@ -63,7 +65,7 @@ public class Henna _cancelCount = set.getInt("cancel_count"); _duration = set.getInt("duration", -1); _skills = new ArrayList<>(); - _wearClass = new ArrayList<>(); + _wearClass = EnumSet.noneOf(ClassId.class); } /** @@ -159,7 +161,7 @@ public class Henna /** * @return the list with the allowed classes to wear this dye. */ - public List getAllowedWearClass() + public Set getAllowedWearClass() { return _wearClass; } diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java index d74b1218d3..5d694e5169 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java @@ -17,9 +17,10 @@ package org.l2jmobius.gameserver.model.item.appearance; import java.time.Duration; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.enums.Race; @@ -47,12 +48,12 @@ public class AppearanceStone private final ArmorType _armorType; private final AppearanceHandType _handType; private final AppearanceMagicType _magicType; - private List _crystalTypes; - private List _targetTypes; - private List _bodyParts; - private List _races; - private List _racesNot; - private List _allVisualIds; + private Set _crystalTypes; + private Set _targetTypes; + private Set _bodyParts; + private Set _races; + private Set _racesNot; + private Set _allVisualIds; public AppearanceStone(StatSet set) { @@ -172,35 +173,35 @@ public class AppearanceStone { if (_crystalTypes == null) { - _crystalTypes = new ArrayList<>(); + _crystalTypes = EnumSet.noneOf(CrystalType.class); } _crystalTypes.add(type); } - public List getCrystalTypes() + public Set getCrystalTypes() { - return _crystalTypes != null ? _crystalTypes : Collections.emptyList(); + return _crystalTypes != null ? _crystalTypes : Collections.emptySet(); } public void addTargetType(AppearanceTargetType type) { if (_targetTypes == null) { - _targetTypes = new ArrayList<>(); + _targetTypes = EnumSet.noneOf(AppearanceTargetType.class); } _targetTypes.add(type); } - public List getTargetTypes() + public Set getTargetTypes() { - return _targetTypes != null ? _targetTypes : Collections.emptyList(); + return _targetTypes != null ? _targetTypes : Collections.emptySet(); } public void addBodyPart(long part) { if (_bodyParts == null) { - _bodyParts = new ArrayList<>(); + _bodyParts = new HashSet<>(); } _bodyParts.add(part); } @@ -209,47 +210,47 @@ public class AppearanceStone { if (_allVisualIds == null) { - _allVisualIds = new ArrayList<>(); + _allVisualIds = new HashSet<>(); } _allVisualIds.add(appearanceHolder); } - public List getVisualIds() + public Set getVisualIds() { - return _allVisualIds != null ? _allVisualIds : Collections.emptyList(); + return _allVisualIds != null ? _allVisualIds : Collections.emptySet(); } - public List getBodyParts() + public Set getBodyParts() { - return _bodyParts != null ? _bodyParts : Collections.emptyList(); + return _bodyParts != null ? _bodyParts : Collections.emptySet(); } public void addRace(Race race) { if (_races == null) { - _races = new ArrayList<>(); + _races = EnumSet.noneOf(Race.class); } _races.add(race); } - public List getRaces() + public Set getRaces() { - return _races != null ? _races : Collections.emptyList(); + return _races != null ? _races : Collections.emptySet(); } public void addRaceNot(Race race) { if (_racesNot == null) { - _racesNot = new ArrayList<>(); + _racesNot = EnumSet.noneOf(Race.class); } _racesNot.add(race); } - public List getRacesNot() + public Set getRacesNot() { - return _racesNot != null ? _racesNot : Collections.emptyList(); + return _racesNot != null ? _racesNot : Collections.emptySet(); } /** @@ -302,7 +303,7 @@ public class AppearanceStone { // Seems like in retail item with already changed appearance, can be changed again without being restored. - final AppearanceTargetType targetType = getTargetTypes().get(0); + final AppearanceTargetType targetType = getTargetTypes().stream().findFirst().get(); switch (targetType) { case NONE: diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java index c21f776020..9af155da21 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java @@ -16,16 +16,16 @@ */ package org.l2jmobius.gameserver.model.item.enchant; +import java.util.EnumSet; +import java.util.Set; import java.util.logging.Logger; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.item.ItemTemplate; import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.model.item.type.CrystalType; import org.l2jmobius.gameserver.model.item.type.EtcItemType; -import org.l2jmobius.gameserver.model.item.type.ItemType; /** * @author UnAfraid @@ -34,28 +34,29 @@ public abstract class AbstractEnchantItem { protected static final Logger LOGGER = Logger.getLogger(AbstractEnchantItem.class.getName()); - private static final ItemType[] ENCHANT_TYPES = new ItemType[] + private static final Set ENCHANT_TYPES = EnumSet.noneOf(EtcItemType.class); + static { - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM, - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP, - EtcItemType.BLESS_ENCHT_AM, - EtcItemType.BLESS_ENCHT_AM_DOWN, - EtcItemType.BLESS_ENCHT_WP, - EtcItemType.ENCHT_AM, - EtcItemType.ENCHT_WP, - EtcItemType.ENCHT_WP_DOWN, - EtcItemType.ENCHT_AM_DOWN, - EtcItemType.GIANT_ENCHT_AM, - EtcItemType.GIANT_ENCHT_WP, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - }; + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP_DOWN); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + } private final int _id; private final CrystalType _grade; @@ -73,7 +74,7 @@ public abstract class AbstractEnchantItem { throw new NullPointerException(); } - else if (!CommonUtil.contains(ENCHANT_TYPES, getItem().getItemType())) + else if (!ENCHANT_TYPES.contains(getItem().getItemType())) { throw new IllegalAccessError(); } diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java index 5ba6755084..18508d0145 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java @@ -24,8 +24,10 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Set; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -184,7 +186,7 @@ public class LongTimeEvent extends Quest final Node maxLevelNode = d.getAttributes().getNamedItem("maxLevel"); final int maxLevel = maxLevelNode == null ? Integer.MAX_VALUE : Integer.parseInt(maxLevelNode.getNodeValue()); final Node monsterIdsNode = d.getAttributes().getNamedItem("monsterIds"); - final List monsterIds = new ArrayList<>(); + final Set monsterIds = new HashSet<>(); if (monsterIdsNode != null) { for (String id : monsterIdsNode.getNodeValue().split(",")) diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/residences/ClanHall.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/residences/ClanHall.java index 0c0a529077..fcc850371b 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/residences/ClanHall.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/residences/ClanHall.java @@ -23,7 +23,9 @@ import java.sql.SQLException; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -61,9 +63,9 @@ public class ClanHall extends AbstractResidence private final int _minBid; final int _lease; private final int _deposit; - private final List _npcs; - private final List _doors; - private final List _teleports; + private final Set _npcs = new HashSet<>(); + private final Set _doors = new HashSet<>(); + private final Set _teleports = new HashSet<>(); private final Location _ownerLocation; private final Location _banishLocation; // Dynamic parameters @@ -85,9 +87,21 @@ public class ClanHall extends AbstractResidence _minBid = params.getInt("minBid"); _lease = params.getInt("lease"); _deposit = params.getInt("deposit"); - _npcs = params.getList("npcList", Integer.class); - _doors = params.getList("doorList", Door.class); - _teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + final List npcs = params.getList("npcList", Integer.class); + if (npcs != null) + { + _npcs.addAll(npcs); + } + final List doors = params.getList("doorList", Door.class); + if (doors != null) + { + _doors.addAll(doors); + } + final List teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + if (teleports != null) + { + _teleports.addAll(teleports); + } _ownerLocation = params.getLocation("owner_loc"); _banishLocation = params.getLocation("banish_loc"); // Set dynamic parameters (from DB) @@ -196,7 +210,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Door} related to this {@link ClanHall}. * @return all {@link Door} related to this {@link ClanHall} */ - public List getDoors() + public Set getDoors() { return _doors; } @@ -205,7 +219,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Npc} related to this {@link ClanHall}. * @return all {@link Npc} related to this {@link ClanHall} */ - public List getNpcs() + public Set getNpcs() { return _npcs; } @@ -324,7 +338,7 @@ public class ClanHall extends AbstractResidence return _banishLocation; } - public List getTeleportList() + public Set getTeleportList() { return _teleports; } diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/siege/Castle.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/siege/Castle.java index 063570e334..27c7525c68 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/siege/Castle.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/siege/Castle.java @@ -21,8 +21,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.Calendar; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -82,7 +84,7 @@ public class Castle extends AbstractResidence private SiegeZone _zone = null; private ResidenceTeleportZone _teleZone; private Clan _formerOwner = null; - private final List _artefacts = new ArrayList<>(1); + private final Set _artefacts = new HashSet<>(1); private final Map _function = new ConcurrentHashMap<>(); private int _ticketBuyCount = 0; private boolean _isFirstMidVictory = false; @@ -1071,7 +1073,7 @@ public class Castle extends AbstractResidence _artefacts.add(artefact); } - public List getArtefacts() + public Set getArtefacts() { return _artefacts; } diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java index 0c79677eae..4ebf954ee5 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.network.serverpackets; -import java.util.List; +import java.util.Set; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.gameserver.data.sql.CharNameTable; @@ -27,19 +27,19 @@ import org.l2jmobius.gameserver.network.OutgoingPackets; */ public class BlockListPacket implements IClientOutgoingPacket { - private final List _playersId; + private final Set _playerIds; - public BlockListPacket(List playersId) + public BlockListPacket(Set playerIds) { - _playersId = playersId; + _playerIds = playerIds; } @Override public boolean write(PacketWriter packet) { OutgoingPackets.BLOCK_LIST.writeId(packet); - packet.writeD(_playersId.size()); - for (int playerId : _playersId) + packet.writeD(_playerIds.size()); + for (int playerId : _playerIds) { packet.writeS(CharNameTable.getInstance().getNameById(playerId)); packet.writeS(""); // memo ? diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java index 8555bb6e86..eb5bfd05d8 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.network.serverpackets; import java.util.List; import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; import org.l2jmobius.commons.network.PacketWriter; @@ -37,7 +38,7 @@ public class ExAcquireSkillInfo implements IClientOutgoingPacket private final int _dualClassLevel; private final long _spCost; private final int _minLevel; - private final List _itemReq; + private final Set _itemReq; private final List _skillRem; /** diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java index 84b5fead76..a163a85735 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java @@ -35,7 +35,7 @@ public class ExChooseShapeShiftingItem implements IClientOutgoingPacket public ExChooseShapeShiftingItem(AppearanceStone stone) { _type = stone.getType(); - _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().get(0); + _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().stream().findFirst().get(); _itemId = stone.getId(); } diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/util/DocumentBase.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/util/DocumentBase.java index 8a8e13d940..c22140b9c4 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/util/DocumentBase.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/util/DocumentBase.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.util; import java.io.File; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -390,12 +391,12 @@ public abstract class DocumentBase case "races": { final String[] racesVal = a.getNodeValue().split(","); - final Race[] races = new Race[racesVal.length]; + final Set races = EnumSet.noneOf(Race.class); for (int r = 0; r < racesVal.length; r++) { if (racesVal[r] != null) { - races[r] = Race.valueOf(racesVal[r]); + races.add(Race.valueOf(racesVal[r])); } } cond = joinAnd(cond, new ConditionPlayerRace(races)); @@ -671,13 +672,13 @@ public abstract class DocumentBase case "instanceid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final ArrayList array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInstanceId(array)); + cond = joinAnd(cond, new ConditionPlayerInstanceId(set)); break; } case "agathionid": @@ -728,10 +729,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -745,10 +746,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -834,13 +835,13 @@ public abstract class DocumentBase case "insidezoneid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInsideZoneId(array)); + cond = joinAnd(cond, new ConditionPlayerInsideZoneId(set)); break; } case "checkabnormal": @@ -961,13 +962,13 @@ public abstract class DocumentBase case "class_id_restriction": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetClassIdRestriction(array)); + cond = joinAnd(cond, new ConditionTargetClassIdRestriction(set)); break; } case "active_effect_id": @@ -1045,13 +1046,13 @@ public abstract class DocumentBase case "npcid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetNpcId(array)); + cond = joinAnd(cond, new ConditionTargetNpcId(set)); break; } case "npctype": diff --git a/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/handlers/bypasshandlers/Link.java b/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/handlers/bypasshandlers/Link.java index 5bd82b732d..360ed1ae88 100644 --- a/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/handlers/bypasshandlers/Link.java +++ b/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/handlers/bypasshandlers/Link.java @@ -16,7 +16,9 @@ */ package handlers.bypasshandlers; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.HashSet; +import java.util.Set; + import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.handler.IBypassHandler; import org.l2jmobius.gameserver.model.actor.Creature; @@ -31,67 +33,68 @@ public class Link implements IBypassHandler "Link" }; - private static final String[] VALID_LINKS = + private static final Set VALID_LINKS = new HashSet<>(); + static { - "common/attribute_info.htm", - "common/augmentation_01.htm", - "common/augmentation_02.htm", - "common/augmentation_exchange.htm", - "common/crafting_01.htm", - "common/crafting_02.htm", - "common/crafting_03.htm", - "common/cursed_to_unidentified.htm", - "common/duals_01.htm", - "common/duals_02.htm", - "common/duals_03.htm", - "common/g_cube_warehouse001.htm", - "common/skill_enchant_help.htm", - "common/skill_enchant_help_01.htm", - "common/skill_enchant_help_02.htm", - "common/skill_enchant_help_03.htm", - "common/smelting_trade001.htm", - "common/weapon_sa_01.htm", - "common/welcomeback002.htm", - "common/welcomeback003.htm", - "default/BlessingOfProtection.htm", - "default/SupportMagic.htm", - "default/SupportMagicServitor.htm", - "fisherman/exchange_old_items.htm", - "fisherman/fish_appearance_exchange.htm", - "fisherman/fishing_manual001.htm", - "fisherman/fishing_manual002.htm", - "fisherman/fishing_manual003.htm", - "fisherman/fishing_manual004.htm", - "fisherman/fishing_manual008.htm", - "fisherman/fishing_manual009.htm", - "fisherman/fishing_manual010.htm", - "fortress/foreman.htm", - "guard/kamaloka_help.htm", - "guard/kamaloka_level.htm", - "petmanager/evolve.htm", - "petmanager/exchange.htm", - "petmanager/instructions.htm", - "teleporter/separatedsoul.htm", - "warehouse/clanwh.htm", - "warehouse/privatewh.htm", + VALID_LINKS.add("common/attribute_info.htm"); + VALID_LINKS.add("common/augmentation_01.htm"); + VALID_LINKS.add("common/augmentation_02.htm"); + VALID_LINKS.add("common/augmentation_exchange.htm"); + VALID_LINKS.add("common/crafting_01.htm"); + VALID_LINKS.add("common/crafting_02.htm"); + VALID_LINKS.add("common/crafting_03.htm"); + VALID_LINKS.add("common/cursed_to_unidentified.htm"); + VALID_LINKS.add("common/duals_01.htm"); + VALID_LINKS.add("common/duals_02.htm"); + VALID_LINKS.add("common/duals_03.htm"); + VALID_LINKS.add("common/g_cube_warehouse001.htm"); + VALID_LINKS.add("common/skill_enchant_help.htm"); + VALID_LINKS.add("common/skill_enchant_help_01.htm"); + VALID_LINKS.add("common/skill_enchant_help_02.htm"); + VALID_LINKS.add("common/skill_enchant_help_03.htm"); + VALID_LINKS.add("common/smelting_trade001.htm"); + VALID_LINKS.add("common/weapon_sa_01.htm"); + VALID_LINKS.add("common/welcomeback002.htm"); + VALID_LINKS.add("common/welcomeback003.htm"); + VALID_LINKS.add("default/BlessingOfProtection.htm"); + VALID_LINKS.add("default/SupportMagic.htm"); + VALID_LINKS.add("default/SupportMagicServitor.htm"); + VALID_LINKS.add("fisherman/exchange_old_items.htm"); + VALID_LINKS.add("fisherman/fish_appearance_exchange.htm"); + VALID_LINKS.add("fisherman/fishing_manual001.htm"); + VALID_LINKS.add("fisherman/fishing_manual002.htm"); + VALID_LINKS.add("fisherman/fishing_manual003.htm"); + VALID_LINKS.add("fisherman/fishing_manual004.htm"); + VALID_LINKS.add("fisherman/fishing_manual008.htm"); + VALID_LINKS.add("fisherman/fishing_manual009.htm"); + VALID_LINKS.add("fisherman/fishing_manual010.htm"); + VALID_LINKS.add("fortress/foreman.htm"); + VALID_LINKS.add("guard/kamaloka_help.htm"); + VALID_LINKS.add("guard/kamaloka_level.htm"); + VALID_LINKS.add("petmanager/evolve.htm"); + VALID_LINKS.add("petmanager/exchange.htm"); + VALID_LINKS.add("petmanager/instructions.htm"); + VALID_LINKS.add("teleporter/separatedsoul.htm"); + VALID_LINKS.add("warehouse/clanwh.htm"); + VALID_LINKS.add("warehouse/privatewh.htm"); // Quests - "teleporter/30006.htm", - "teleporter/30006-Q561.htm", - "teleporter/30006-Q561-1.htm", - "teleporter/30006-Q561-2.htm", - "teleporter/30134.htm", - "teleporter/30134-Q562.htm", - "teleporter/30134-Q562-1.htm", - "teleporter/30134-Q562-2.htm", - "teleporter/30256.htm", - "teleporter/30256-Q562.htm", - "teleporter/30256-Q562-1.htm", - "teleporter/30256-Q562-2.htm", - "teleporter/30848.htm", - "teleporter/30848-Q561-Q562.htm", - "teleporter/30848-Q561-Q562-1.htm", - "teleporter/30848-Q561-Q562-2.htm", - }; + VALID_LINKS.add("teleporter/30006.htm"); + VALID_LINKS.add("teleporter/30006-Q561.htm"); + VALID_LINKS.add("teleporter/30006-Q561-1.htm"); + VALID_LINKS.add("teleporter/30006-Q561-2.htm"); + VALID_LINKS.add("teleporter/30134.htm"); + VALID_LINKS.add("teleporter/30134-Q562.htm"); + VALID_LINKS.add("teleporter/30134-Q562-1.htm"); + VALID_LINKS.add("teleporter/30134-Q562-2.htm"); + VALID_LINKS.add("teleporter/30256.htm"); + VALID_LINKS.add("teleporter/30256-Q562.htm"); + VALID_LINKS.add("teleporter/30256-Q562-1.htm"); + VALID_LINKS.add("teleporter/30256-Q562-2.htm"); + VALID_LINKS.add("teleporter/30848.htm"); + VALID_LINKS.add("teleporter/30848-Q561-Q562.htm"); + VALID_LINKS.add("teleporter/30848-Q561-Q562-1.htm"); + VALID_LINKS.add("teleporter/30848-Q561-Q562-2.htm"); + } @Override public boolean useBypass(String command, Player player, Creature target) @@ -109,12 +112,13 @@ public class Link implements IBypassHandler return false; } - String content = CommonUtil.contains(VALID_LINKS, htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; + String content = VALID_LINKS.contains(htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; // Precaution. if (htmlPath.startsWith("teleporter/") && !(player.getTarget() instanceof Teleporter)) { content = null; } + final NpcHtmlMessage html = new NpcHtmlMessage(target != null ? target.getObjectId() : 0); if (content != null) { diff --git a/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/handlers/itemhandlers/PetFood.java b/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/handlers/itemhandlers/PetFood.java index 3c5572d4ec..8b908ea095 100644 --- a/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/handlers/itemhandlers/PetFood.java +++ b/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/handlers/itemhandlers/PetFood.java @@ -17,6 +17,7 @@ package handlers.itemhandlers; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.PetDataTable; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -79,7 +80,7 @@ public class PetFood implements IItemHandler final Player player = activeChar.getActingPlayer(); if (player.isMounted()) { - final List foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); + final Set foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); if (foodIds.contains(item.getId()) && player.destroyItem("Consume", item.getObjectId(), 1, null, false)) { player.broadcastPacket(new MagicSkillUse(player, player, skillId, skillLevel, 0, 0)); diff --git a/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java b/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java index 2ad282f683..99f45fbb41 100644 --- a/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java +++ b/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.ClanHallData; import org.l2jmobius.gameserver.model.StatSet; @@ -32,12 +33,12 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpCheckResidenceSkillCondition implements ISkillCondition { - private final List _residencesId; + private final Set _residencesId = new HashSet<>(); private final boolean _isWithin; public OpCheckResidenceSkillCondition(StatSet params) { - _residencesId = params.getList("residencesId", Integer.class); + _residencesId.addAll(params.getList("residencesId", Integer.class)); _isWithin = params.getBoolean("isWithin"); } diff --git a/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java b/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java index fc2934423b..4a8282d988 100644 --- a/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java +++ b/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java @@ -16,9 +16,9 @@ */ package handlers.skillconditionhandlers; -import java.util.ArrayList; -import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -28,18 +28,18 @@ import org.l2jmobius.gameserver.model.skill.ISkillCondition; import org.l2jmobius.gameserver.model.skill.Skill; /** - * @author UnAfraid + * @author UnAfraid, Mobius */ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition { - private final List _npcIds = new ArrayList<>(); + private final Set _npcIds = new HashSet<>(); public OpNeedSummonOrPetSkillCondition(StatSet params) { - final List npcIds = params.getList("npcIds", String.class); + final List npcIds = params.getList("npcIds", Integer.class); if (npcIds != null) { - npcIds.stream().map(Integer::valueOf).forEach(_npcIds::add); + _npcIds.addAll(npcIds); } } @@ -47,7 +47,19 @@ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition public boolean canUse(Creature caster, Skill skill, WorldObject target) { final Summon pet = caster.getPet(); - final Collection summons = caster.getServitors().values(); - return ((pet != null) && _npcIds.stream().anyMatch(npcId -> npcId == pet.getId())) || summons.stream().anyMatch(summon -> _npcIds.contains(summon.getId())); + if ((pet != null) && _npcIds.contains(pet.getId())) + { + return true; + } + + for (Summon summon : caster.getServitors().values()) + { + if (_npcIds.contains(summon.getId())) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java b/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java index 8541bc62b4..ef81b291d4 100644 --- a/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java +++ b/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,11 +30,11 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetDoorSkillCondition implements ISkillCondition { - private final List _doorIds; + private final Set _doorIds = new HashSet<>(); public OpTargetDoorSkillCondition(StatSet params) { - _doorIds = params.getList("doorIds", Integer.class); + _doorIds.addAll(params.getList("doorIds", Integer.class)); } @Override diff --git a/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java b/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java index 3ce4145703..0ccd571e19 100644 --- a/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java +++ b/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,17 +30,17 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetNpcSkillCondition implements ISkillCondition { - private final List _npcId; + private final Set _npcIds = new HashSet<>(); public OpTargetNpcSkillCondition(StatSet params) { - _npcId = params.getList("npcIds", Integer.class); + _npcIds.addAll(params.getList("npcIds", Integer.class)); } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget(); - return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId()); + return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcIds.contains(actualTarget.getId()); } } diff --git a/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/instances/AbstractInstance.java b/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/instances/AbstractInstance.java index 94c337f0df..a5b4ef238a 100644 --- a/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/instances/AbstractInstance.java +++ b/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/instances/AbstractInstance.java @@ -16,9 +16,10 @@ */ package instances; +import java.util.HashSet; import java.util.List; +import java.util.Set; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.enums.InstanceReenterType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.instancemanager.InstanceManager; @@ -40,25 +41,29 @@ import ai.AbstractNpcAI; */ public abstract class AbstractInstance extends AbstractNpcAI { - private final int[] _templateIds; + private final Set _templateIds = new HashSet<>(); - public AbstractInstance(int... templateId) + public AbstractInstance(int... templateIds) { - if (templateId.length == 0) + if (templateIds.length == 0) { throw new IllegalStateException("No template ids were provided!"); } - _templateIds = templateId; + + for (int templateId : templateIds) + { + _templateIds.add(templateId); + } } - public int[] getTemplateId() + public Set getTemplateId() { return _templateIds; } public boolean isInInstance(Instance instance) { - return (instance != null) && CommonUtil.contains(_templateIds, instance.getTemplateId()); + return (instance != null) && _templateIds.contains(instance.getTemplateId()); } /** diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/Config.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/Config.java index 60f3917267..327a349dec 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/Config.java @@ -286,7 +286,7 @@ public class Config public static boolean AUTO_LOOT_SLOT_LIMIT; public static int LOOT_RAIDS_PRIVILEGE_INTERVAL; public static int LOOT_RAIDS_PRIVILEGE_CC_SIZE; - public static List AUTO_LOOT_ITEM_IDS; + public static Set AUTO_LOOT_ITEM_IDS; public static boolean ENABLE_KEYBOARD_MOVEMENT; public static int UNSTUCK_INTERVAL; public static int TELEPORT_WATCHDOG_TIMEOUT; @@ -454,7 +454,7 @@ public class Config public static boolean ALLOW_DISCARDITEM; public static int AUTODESTROY_ITEM_AFTER; public static int HERB_AUTO_DESTROY_TIME; - public static List LIST_PROTECTED_ITEMS; + public static Set LIST_PROTECTED_ITEMS; public static boolean DATABASE_CLEAN_UP; public static int CHAR_DATA_STORE_INTERVAL; public static int CLAN_VARIABLES_STORE_INTERVAL; @@ -547,7 +547,7 @@ public class Config public static boolean ALT_OLY_LOG_FIGHTS; public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS; public static boolean ALT_OLY_ANNOUNCE_GAMES; - public static List LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(); + public static Set LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(); public static int ALT_OLY_WEAPON_ENCHANT_LIMIT; public static int ALT_OLY_ARMOR_ENCHANT_LIMIT; public static int ALT_OLY_WAIT_TIME; @@ -1212,9 +1212,9 @@ public class Config public static int AUTO_CP_PERCENTAGE; public static int AUTO_HP_PERCENTAGE; public static int AUTO_MP_PERCENTAGE; - public static List AUTO_CP_ITEM_IDS; - public static List AUTO_HP_ITEM_IDS; - public static List AUTO_MP_ITEM_IDS; + public static Set AUTO_CP_ITEM_IDS; + public static Set AUTO_HP_ITEM_IDS; + public static Set AUTO_MP_ITEM_IDS; public static boolean CUSTOM_STARTING_LOC; public static int CUSTOM_STARTING_LOC_X; public static int CUSTOM_STARTING_LOC_Y; @@ -1224,7 +1224,7 @@ public class Config public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; public static int MOB_MIN_SPAWN_RANGE; public static int MOB_MAX_SPAWN_RANGE; - public static List MOBS_LIST_NOT_RANDOM; + public static Set MOBS_LIST_NOT_RANDOM; public static boolean FREE_JUMPS_FOR_ALL; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; @@ -1243,7 +1243,7 @@ public class Config public static boolean COMMUNITY_PREMIUM_SYSTEM_ENABLED; public static int COMMUNITY_PREMIUM_COIN_ID; public static int COMMUNITY_PREMIUM_PRICE_PER_DAY; - public static List COMMUNITY_AVAILABLE_BUFFS; + public static Set COMMUNITY_AVAILABLE_BUFFS; public static Map COMMUNITY_AVAILABLE_TELEPORTS; public static boolean CUSTOM_DEPOSITABLE_ENABLED; public static boolean CUSTOM_DEPOSITABLE_QUEST_ITEMS; @@ -1898,7 +1898,7 @@ public class Config LOOT_RAIDS_PRIVILEGE_INTERVAL = characterConfig.getInt("RaidLootRightsInterval", 900) * 1000; LOOT_RAIDS_PRIVILEGE_CC_SIZE = characterConfig.getInt("RaidLootRightsCCSize", 45); final String[] autoLootItemIds = characterConfig.getString("AutoLootItemIds", "0").split(","); - AUTO_LOOT_ITEM_IDS = new ArrayList<>(autoLootItemIds.length); + AUTO_LOOT_ITEM_IDS = new HashSet<>(autoLootItemIds.length); for (String item : autoLootItemIds) { Integer itm = 0; @@ -2017,7 +2017,7 @@ public class Config AUTODESTROY_ITEM_AFTER = generalConfig.getInt("AutoDestroyDroppedItemAfter", 600); HERB_AUTO_DESTROY_TIME = generalConfig.getInt("AutoDestroyHerbTime", 60) * 1000; final String[] split = generalConfig.getString("ListOfProtectedItems", "0").split(","); - LIST_PROTECTED_ITEMS = new ArrayList<>(split.length); + LIST_PROTECTED_ITEMS = new HashSet<>(split.length); for (String id : split) { LIST_PROTECTED_ITEMS.add(Integer.parseInt(id)); @@ -2415,7 +2415,7 @@ public class Config if (!olyRestrictedItems.isEmpty()) { final String[] olyRestrictedItemsSplit = olyRestrictedItems.split(","); - LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(olyRestrictedItemsSplit.length); + LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(olyRestrictedItemsSplit.length); for (String id : olyRestrictedItemsSplit) { LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id)); @@ -2572,17 +2572,17 @@ public class Config AUTO_CP_PERCENTAGE = autoPotionsConfig.getInt("AutoCpPercentage", 70); AUTO_HP_PERCENTAGE = autoPotionsConfig.getInt("AutoHpPercentage", 70); AUTO_MP_PERCENTAGE = autoPotionsConfig.getInt("AutoMpPercentage", 70); - AUTO_CP_ITEM_IDS = new ArrayList<>(); + AUTO_CP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoCpItemIds", "0").split(",")) { AUTO_CP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_HP_ITEM_IDS = new ArrayList<>(); + AUTO_HP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoHpItemIds", "0").split(",")) { AUTO_HP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_MP_ITEM_IDS = new ArrayList<>(); + AUTO_MP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoMpItemIds", "0").split(",")) { AUTO_MP_ITEM_IDS.add(Integer.parseInt(s)); @@ -3193,7 +3193,7 @@ public class Config COMMUNITY_PREMIUM_COIN_ID = communityBoardConfig.getInt("CommunityPremiumBuyCoinId", 57); COMMUNITY_PREMIUM_PRICE_PER_DAY = communityBoardConfig.getInt("CommunityPremiumPricePerDay", 1000000); final String[] allowedBuffs = communityBoardConfig.getString("CommunityAvailableBuffs", "").split(","); - COMMUNITY_AVAILABLE_BUFFS = new ArrayList<>(allowedBuffs.length); + COMMUNITY_AVAILABLE_BUFFS = new HashSet<>(allowedBuffs.length); for (String s : allowedBuffs) { COMMUNITY_AVAILABLE_BUFFS.add(Integer.parseInt(s)); @@ -3500,7 +3500,7 @@ public class Config if (ENABLE_RANDOM_MONSTER_SPAWNS) { final String[] mobsIds = randomSpawnsConfig.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); - MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + MOBS_LIST_NOT_RANDOM = new HashSet<>(mobsIds.length); for (String id : mobsIds) { MOBS_LIST_NOT_RANDOM.add(Integer.parseInt(id)); diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java index d6e0183c6f..c3977185b4 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java @@ -202,8 +202,7 @@ public class ClanHallData implements IXmlReader final Door door = DoorData.getInstance().getDoor(doorId); for (ClanHall ch : _clanHalls.values()) { - final List doors = ch.getDoors(); - if ((doors != null) && doors.contains(door)) + if (ch.getDoors().contains(door)) { return ch; } diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java index 6aa0a1fdde..fb395b9e2d 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java @@ -17,10 +17,10 @@ package org.l2jmobius.gameserver.data.xml; import java.io.File; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -42,7 +42,7 @@ public class FakePlayerData implements IXmlReader private final Map _fakePlayerInfos = new HashMap<>(); private final Map _fakePlayerNames = new HashMap<>(); private final Map _fakePlayerIds = new HashMap<>(); - private final List _talkableFakePlayerNames = new ArrayList<>(); + private final Set _talkableFakePlayerNames = new HashSet<>(); protected FakePlayerData() { diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java index d335b95954..1122d7b9ba 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java @@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -49,7 +51,7 @@ import org.l2jmobius.gameserver.util.Util; public class SellBuffsManager implements IXmlReader { private static final Logger LOGGER = Logger.getLogger(SellBuffsManager.class.getName()); - private static final List ALLOWED_BUFFS = new ArrayList<>(); + private static final Set ALLOWED_BUFFS = new HashSet<>(); private static final String HTML_FOLDER = "data/html/mods/SellBuffs/"; protected SellBuffsManager() @@ -76,11 +78,7 @@ public class SellBuffsManager implements IXmlReader { final Element elem = (Element) node.item(i); final int skillId = Integer.parseInt(elem.getAttribute("id")); - - if (!ALLOWED_BUFFS.contains(skillId)) - { - ALLOWED_BUFFS.add(skillId); - } + ALLOWED_BUFFS.add(skillId); } } diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java index b10f75ef3d..1e45a21319 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java @@ -19,8 +19,10 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; @@ -67,7 +69,7 @@ public class WalkingManager implements IXmlReader public static final byte REPEAT_TELE_FIRST = 2; public static final byte REPEAT_RANDOM = 3; - private final List _targetedNpcIds = new ArrayList<>(); + private final Set _targetedNpcIds = new HashSet<>(); private final Map _routes = new HashMap<>(); // all available routes private final Map _activeRoutes = new HashMap<>(); // each record represents NPC, moving by predefined route from _routes, and moving progress private final Map _routesToAttach = new HashMap<>(); // each record represents NPC and all available routes for it diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/BlockList.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/BlockList.java index 1af9941ed5..9ac6266e22 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/BlockList.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/BlockList.java @@ -19,9 +19,9 @@ package org.l2jmobius.gameserver.model; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -36,10 +36,11 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; public class BlockList { private static final Logger LOGGER = Logger.getLogger(BlockList.class.getName()); - private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); + + private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); private final Player _owner; - private List _blockList; + private Set _blockList; public BlockList(Player owner) { @@ -68,9 +69,9 @@ public class BlockList OFFLINE_LIST.put(_owner.getObjectId(), _blockList); } - private static List loadList(int objId) + private static Set loadList(int objId) { - final List list = new ArrayList<>(); + final Set list = new HashSet<>(); try (Connection con = DatabaseFactory.getConnection(); PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1")) { @@ -158,7 +159,7 @@ public class BlockList _owner.setMessageRefusal(value); } - private List getBlockList() + private Set getBlockList() { return _blockList; } diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/PetData.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/PetData.java index b534c21f36..231b85e85f 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/PetData.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/PetData.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; import org.l2jmobius.gameserver.model.holders.SkillHolder; @@ -40,7 +42,7 @@ public class PetData private int _minLevel = Byte.MAX_VALUE; private int _maxLevel = 0; private boolean _syncLevel = false; - private final List _food = new ArrayList<>(); + private final Set _food = new HashSet<>(); public PetData(int npcId, int itemId) { @@ -133,7 +135,7 @@ public class PetData /** * @return the pet's food list. */ - public List getFood() + public Set getFood() { return _food; } diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/SkillLearn.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/SkillLearn.java index a69d30f105..3d5704b5f2 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/SkillLearn.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/SkillLearn.java @@ -16,9 +16,8 @@ */ package org.l2jmobius.gameserver.model; -import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashSet; -import java.util.List; import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -40,12 +39,12 @@ public class SkillLearn private final int _getDualClassLevel; private final boolean _autoGet; private final long _levelUpSp; - private final List _requiredItems = new ArrayList<>(); - private final List _races = new ArrayList<>(); - private final List _preReqSkills = new ArrayList<>(); + private final Set _requiredItems = new HashSet<>(1); + private final Set _races = EnumSet.noneOf(Race.class); + private final Set _preReqSkills = new HashSet<>(1); private SocialClass _socialClass; private final boolean _residenceSkill; - private final List _residenceIds = new ArrayList<>(); + private final Set _residenceIds = new HashSet<>(1); private final boolean _learnedByNpc; private final boolean _learnedByFS; private final Set _removeSkills = new HashSet<>(1); @@ -133,9 +132,9 @@ public class SkillLearn } /** - * @return the list with the item holders required to acquire this skill. + * @return the set with the item holders required to acquire this skill. */ - public List getRequiredItems() + public Set getRequiredItems() { return _requiredItems; } @@ -150,9 +149,9 @@ public class SkillLearn } /** - * @return a list with the races that can acquire this skill. + * @return a set with the races that can acquire this skill. */ - public List getRaces() + public Set getRaces() { return _races; } @@ -167,9 +166,9 @@ public class SkillLearn } /** - * @return the list of skill holders required to acquire this skill. + * @return the set of skill holders required to acquire this skill. */ - public List getPreReqSkills() + public Set getPreReqSkills() { return _preReqSkills; } @@ -212,9 +211,9 @@ public class SkillLearn } /** - * @return a list with the Ids where this skill is available. + * @return a set with the Ids where this skill is available. */ - public List getResidenceIds() + public Set getResidenceIds() { return _residenceIds; } diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java index 76d810a2d9..3b04eafa72 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java @@ -22,7 +22,6 @@ import java.sql.ResultSet; import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.List; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; @@ -153,7 +152,7 @@ public class Pet extends Summon broadcastStatusUpdate(); - final List foodIds = getPetData().getFood(); + final Set foodIds = getPetData().getFood(); if (foodIds.isEmpty()) { if (isUncontrollable()) diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java index 11efe435d8..1ed0ee81a4 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java @@ -16,8 +16,8 @@ */ package org.l2jmobius.gameserver.model.actor.instance; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import org.l2jmobius.commons.threads.ThreadPool; @@ -57,7 +57,7 @@ public class Trap extends Npc private boolean _isTriggered; private final int _lifeTime; private Player _owner; - private final List _playersWhoDetectedMe = new ArrayList<>(); + private final Set _playersWhoDetectedMe = new HashSet<>(); private final SkillHolder _skill; private int _remainingTime; // Tasks diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java index 71ef076212..3ba8c20a9b 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor.tasks.player; -import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -69,11 +69,12 @@ public class PetFeedTask implements Runnable _player.sendPacket(SystemMessageId.YOU_ARE_OUT_OF_FEED_MOUNT_STATUS_CANCELED); } - final List foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); + final Set foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); if (foodIds.isEmpty()) { return; } + Item food = null; for (int id : foodIds) { diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java index 50d2a821c3..2611b5f121 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.actor.Creature; @@ -29,9 +29,9 @@ import org.l2jmobius.gameserver.model.zone.ZoneType; */ public class ConditionPlayerInsideZoneId extends Condition { - private final List _zones; + private final Set _zones; - public ConditionPlayerInsideZoneId(List zones) + public ConditionPlayerInsideZoneId(Set zones) { _zones = zones; } diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java index c15065eca2..d644f663f5 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Player; @@ -29,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerInstanceId extends Condition { - private final List _instanceIds; + private final Set _instanceIds; /** * Instantiates a new condition player instance id. * @param instanceIds the instance ids */ - public ConditionPlayerInstanceId(List instanceIds) + public ConditionPlayerInstanceId(Set instanceIds) { _instanceIds = instanceIds; } diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java index 14d61089ed..7c375ec45e 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -28,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerRace extends Condition { - private final Race[] _races; + private final Set _races; /** * Instantiates a new condition player race. * @param races the list containing the allowed races. */ - public ConditionPlayerRace(Race[] races) + public ConditionPlayerRace(Set races) { _races = races; } @@ -46,6 +47,6 @@ public class ConditionPlayerRace extends Condition { return false; } - return CommonUtil.contains(_races, effector.getActingPlayer().getRace()); + return _races.contains(effector.getActingPlayer().getRace()); } } diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java index 0f54766571..0b326e3f40 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId())) + if (_npcIds.contains(target.getId())) { existNpc = true; break; diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java index c5c9b5ff0e..db64b6bd7b 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromSummonedNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromSummonedNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromSummonedNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromSummonedNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId()) && (effector == target.getSummoner())) + if (_npcIds.contains(target.getId()) && (effector == target.getSummoner())) { existNpc = true; break; diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java index a3fb0f5374..a47b4b4983 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetClassIdRestriction extends Condition { - private final List _classIds; + private final Set _classIds; /** * Instantiates a new condition target class id restriction. * @param classId the class id */ - public ConditionTargetClassIdRestriction(List classId) + public ConditionTargetClassIdRestriction(Set classId) { _classIds = classId; } diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java index 82b1bd5877..9bb694f4ef 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetNpcId extends Condition { - private final List _npcIds; + private final Set _npcIds; /** * Instantiates a new condition target npc id. * @param npcIds the npc ids */ - public ConditionTargetNpcId(List npcIds) + public ConditionTargetNpcId(Set npcIds) { _npcIds = npcIds; } diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java index f26329bc21..5c86f26ae5 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.holders; -import java.util.Collection; +import java.util.Set; /** * @author Mobius @@ -25,9 +25,9 @@ public class EventDropHolder extends DropHolder { private final int _minLevel; private final int _maxLevel; - private final Collection _monsterIds; + private final Set _monsterIds; - public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Collection monsterIds) + public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Set monsterIds) { super(null, itemId, min, max, chance); _minLevel = minLevel; @@ -45,7 +45,7 @@ public class EventDropHolder extends DropHolder return _maxLevel; } - public Collection getMonsterIds() + public Set getMonsterIds() { return _monsterIds; } diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/item/Henna.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/item/Henna.java index af805ac1bc..6c2c9feea3 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/item/Henna.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/item/Henna.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model.item; import java.util.ArrayList; import java.util.EnumMap; +import java.util.EnumSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.enums.ClassId; import org.l2jmobius.gameserver.model.StatSet; @@ -42,7 +44,7 @@ public class Henna private final int _cancelCount; private final int _duration; private final List _skills; - private final List _wearClass; + private final Set _wearClass; public Henna(StatSet set) { @@ -63,7 +65,7 @@ public class Henna _cancelCount = set.getInt("cancel_count"); _duration = set.getInt("duration", -1); _skills = new ArrayList<>(); - _wearClass = new ArrayList<>(); + _wearClass = EnumSet.noneOf(ClassId.class); } /** @@ -159,7 +161,7 @@ public class Henna /** * @return the list with the allowed classes to wear this dye. */ - public List getAllowedWearClass() + public Set getAllowedWearClass() { return _wearClass; } diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java index d74b1218d3..5d694e5169 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java @@ -17,9 +17,10 @@ package org.l2jmobius.gameserver.model.item.appearance; import java.time.Duration; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.enums.Race; @@ -47,12 +48,12 @@ public class AppearanceStone private final ArmorType _armorType; private final AppearanceHandType _handType; private final AppearanceMagicType _magicType; - private List _crystalTypes; - private List _targetTypes; - private List _bodyParts; - private List _races; - private List _racesNot; - private List _allVisualIds; + private Set _crystalTypes; + private Set _targetTypes; + private Set _bodyParts; + private Set _races; + private Set _racesNot; + private Set _allVisualIds; public AppearanceStone(StatSet set) { @@ -172,35 +173,35 @@ public class AppearanceStone { if (_crystalTypes == null) { - _crystalTypes = new ArrayList<>(); + _crystalTypes = EnumSet.noneOf(CrystalType.class); } _crystalTypes.add(type); } - public List getCrystalTypes() + public Set getCrystalTypes() { - return _crystalTypes != null ? _crystalTypes : Collections.emptyList(); + return _crystalTypes != null ? _crystalTypes : Collections.emptySet(); } public void addTargetType(AppearanceTargetType type) { if (_targetTypes == null) { - _targetTypes = new ArrayList<>(); + _targetTypes = EnumSet.noneOf(AppearanceTargetType.class); } _targetTypes.add(type); } - public List getTargetTypes() + public Set getTargetTypes() { - return _targetTypes != null ? _targetTypes : Collections.emptyList(); + return _targetTypes != null ? _targetTypes : Collections.emptySet(); } public void addBodyPart(long part) { if (_bodyParts == null) { - _bodyParts = new ArrayList<>(); + _bodyParts = new HashSet<>(); } _bodyParts.add(part); } @@ -209,47 +210,47 @@ public class AppearanceStone { if (_allVisualIds == null) { - _allVisualIds = new ArrayList<>(); + _allVisualIds = new HashSet<>(); } _allVisualIds.add(appearanceHolder); } - public List getVisualIds() + public Set getVisualIds() { - return _allVisualIds != null ? _allVisualIds : Collections.emptyList(); + return _allVisualIds != null ? _allVisualIds : Collections.emptySet(); } - public List getBodyParts() + public Set getBodyParts() { - return _bodyParts != null ? _bodyParts : Collections.emptyList(); + return _bodyParts != null ? _bodyParts : Collections.emptySet(); } public void addRace(Race race) { if (_races == null) { - _races = new ArrayList<>(); + _races = EnumSet.noneOf(Race.class); } _races.add(race); } - public List getRaces() + public Set getRaces() { - return _races != null ? _races : Collections.emptyList(); + return _races != null ? _races : Collections.emptySet(); } public void addRaceNot(Race race) { if (_racesNot == null) { - _racesNot = new ArrayList<>(); + _racesNot = EnumSet.noneOf(Race.class); } _racesNot.add(race); } - public List getRacesNot() + public Set getRacesNot() { - return _racesNot != null ? _racesNot : Collections.emptyList(); + return _racesNot != null ? _racesNot : Collections.emptySet(); } /** @@ -302,7 +303,7 @@ public class AppearanceStone { // Seems like in retail item with already changed appearance, can be changed again without being restored. - final AppearanceTargetType targetType = getTargetTypes().get(0); + final AppearanceTargetType targetType = getTargetTypes().stream().findFirst().get(); switch (targetType) { case NONE: diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java index c21f776020..9af155da21 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java @@ -16,16 +16,16 @@ */ package org.l2jmobius.gameserver.model.item.enchant; +import java.util.EnumSet; +import java.util.Set; import java.util.logging.Logger; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.item.ItemTemplate; import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.model.item.type.CrystalType; import org.l2jmobius.gameserver.model.item.type.EtcItemType; -import org.l2jmobius.gameserver.model.item.type.ItemType; /** * @author UnAfraid @@ -34,28 +34,29 @@ public abstract class AbstractEnchantItem { protected static final Logger LOGGER = Logger.getLogger(AbstractEnchantItem.class.getName()); - private static final ItemType[] ENCHANT_TYPES = new ItemType[] + private static final Set ENCHANT_TYPES = EnumSet.noneOf(EtcItemType.class); + static { - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM, - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP, - EtcItemType.BLESS_ENCHT_AM, - EtcItemType.BLESS_ENCHT_AM_DOWN, - EtcItemType.BLESS_ENCHT_WP, - EtcItemType.ENCHT_AM, - EtcItemType.ENCHT_WP, - EtcItemType.ENCHT_WP_DOWN, - EtcItemType.ENCHT_AM_DOWN, - EtcItemType.GIANT_ENCHT_AM, - EtcItemType.GIANT_ENCHT_WP, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - }; + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP_DOWN); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + } private final int _id; private final CrystalType _grade; @@ -73,7 +74,7 @@ public abstract class AbstractEnchantItem { throw new NullPointerException(); } - else if (!CommonUtil.contains(ENCHANT_TYPES, getItem().getItemType())) + else if (!ENCHANT_TYPES.contains(getItem().getItemType())) { throw new IllegalAccessError(); } diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java index 5ba6755084..18508d0145 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java @@ -24,8 +24,10 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Set; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -184,7 +186,7 @@ public class LongTimeEvent extends Quest final Node maxLevelNode = d.getAttributes().getNamedItem("maxLevel"); final int maxLevel = maxLevelNode == null ? Integer.MAX_VALUE : Integer.parseInt(maxLevelNode.getNodeValue()); final Node monsterIdsNode = d.getAttributes().getNamedItem("monsterIds"); - final List monsterIds = new ArrayList<>(); + final Set monsterIds = new HashSet<>(); if (monsterIdsNode != null) { for (String id : monsterIdsNode.getNodeValue().split(",")) diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/residences/ClanHall.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/residences/ClanHall.java index 0c0a529077..fcc850371b 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/residences/ClanHall.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/residences/ClanHall.java @@ -23,7 +23,9 @@ import java.sql.SQLException; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -61,9 +63,9 @@ public class ClanHall extends AbstractResidence private final int _minBid; final int _lease; private final int _deposit; - private final List _npcs; - private final List _doors; - private final List _teleports; + private final Set _npcs = new HashSet<>(); + private final Set _doors = new HashSet<>(); + private final Set _teleports = new HashSet<>(); private final Location _ownerLocation; private final Location _banishLocation; // Dynamic parameters @@ -85,9 +87,21 @@ public class ClanHall extends AbstractResidence _minBid = params.getInt("minBid"); _lease = params.getInt("lease"); _deposit = params.getInt("deposit"); - _npcs = params.getList("npcList", Integer.class); - _doors = params.getList("doorList", Door.class); - _teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + final List npcs = params.getList("npcList", Integer.class); + if (npcs != null) + { + _npcs.addAll(npcs); + } + final List doors = params.getList("doorList", Door.class); + if (doors != null) + { + _doors.addAll(doors); + } + final List teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + if (teleports != null) + { + _teleports.addAll(teleports); + } _ownerLocation = params.getLocation("owner_loc"); _banishLocation = params.getLocation("banish_loc"); // Set dynamic parameters (from DB) @@ -196,7 +210,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Door} related to this {@link ClanHall}. * @return all {@link Door} related to this {@link ClanHall} */ - public List getDoors() + public Set getDoors() { return _doors; } @@ -205,7 +219,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Npc} related to this {@link ClanHall}. * @return all {@link Npc} related to this {@link ClanHall} */ - public List getNpcs() + public Set getNpcs() { return _npcs; } @@ -324,7 +338,7 @@ public class ClanHall extends AbstractResidence return _banishLocation; } - public List getTeleportList() + public Set getTeleportList() { return _teleports; } diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/siege/Castle.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/siege/Castle.java index 063570e334..27c7525c68 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/siege/Castle.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/siege/Castle.java @@ -21,8 +21,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.Calendar; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -82,7 +84,7 @@ public class Castle extends AbstractResidence private SiegeZone _zone = null; private ResidenceTeleportZone _teleZone; private Clan _formerOwner = null; - private final List _artefacts = new ArrayList<>(1); + private final Set _artefacts = new HashSet<>(1); private final Map _function = new ConcurrentHashMap<>(); private int _ticketBuyCount = 0; private boolean _isFirstMidVictory = false; @@ -1071,7 +1073,7 @@ public class Castle extends AbstractResidence _artefacts.add(artefact); } - public List getArtefacts() + public Set getArtefacts() { return _artefacts; } diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java index 0c79677eae..4ebf954ee5 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.network.serverpackets; -import java.util.List; +import java.util.Set; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.gameserver.data.sql.CharNameTable; @@ -27,19 +27,19 @@ import org.l2jmobius.gameserver.network.OutgoingPackets; */ public class BlockListPacket implements IClientOutgoingPacket { - private final List _playersId; + private final Set _playerIds; - public BlockListPacket(List playersId) + public BlockListPacket(Set playerIds) { - _playersId = playersId; + _playerIds = playerIds; } @Override public boolean write(PacketWriter packet) { OutgoingPackets.BLOCK_LIST.writeId(packet); - packet.writeD(_playersId.size()); - for (int playerId : _playersId) + packet.writeD(_playerIds.size()); + for (int playerId : _playerIds) { packet.writeS(CharNameTable.getInstance().getNameById(playerId)); packet.writeS(""); // memo ? diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java index 8555bb6e86..eb5bfd05d8 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.network.serverpackets; import java.util.List; import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; import org.l2jmobius.commons.network.PacketWriter; @@ -37,7 +38,7 @@ public class ExAcquireSkillInfo implements IClientOutgoingPacket private final int _dualClassLevel; private final long _spCost; private final int _minLevel; - private final List _itemReq; + private final Set _itemReq; private final List _skillRem; /** diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java index 84b5fead76..a163a85735 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java @@ -35,7 +35,7 @@ public class ExChooseShapeShiftingItem implements IClientOutgoingPacket public ExChooseShapeShiftingItem(AppearanceStone stone) { _type = stone.getType(); - _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().get(0); + _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().stream().findFirst().get(); _itemId = stone.getId(); } diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/util/DocumentBase.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/util/DocumentBase.java index 8a8e13d940..c22140b9c4 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/util/DocumentBase.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/util/DocumentBase.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.util; import java.io.File; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -390,12 +391,12 @@ public abstract class DocumentBase case "races": { final String[] racesVal = a.getNodeValue().split(","); - final Race[] races = new Race[racesVal.length]; + final Set races = EnumSet.noneOf(Race.class); for (int r = 0; r < racesVal.length; r++) { if (racesVal[r] != null) { - races[r] = Race.valueOf(racesVal[r]); + races.add(Race.valueOf(racesVal[r])); } } cond = joinAnd(cond, new ConditionPlayerRace(races)); @@ -671,13 +672,13 @@ public abstract class DocumentBase case "instanceid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final ArrayList array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInstanceId(array)); + cond = joinAnd(cond, new ConditionPlayerInstanceId(set)); break; } case "agathionid": @@ -728,10 +729,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -745,10 +746,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -834,13 +835,13 @@ public abstract class DocumentBase case "insidezoneid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInsideZoneId(array)); + cond = joinAnd(cond, new ConditionPlayerInsideZoneId(set)); break; } case "checkabnormal": @@ -961,13 +962,13 @@ public abstract class DocumentBase case "class_id_restriction": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetClassIdRestriction(array)); + cond = joinAnd(cond, new ConditionTargetClassIdRestriction(set)); break; } case "active_effect_id": @@ -1045,13 +1046,13 @@ public abstract class DocumentBase case "npcid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetNpcId(array)); + cond = joinAnd(cond, new ConditionTargetNpcId(set)); break; } case "npctype": diff --git a/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/bypasshandlers/Link.java b/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/bypasshandlers/Link.java index 5bd82b732d..360ed1ae88 100644 --- a/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/bypasshandlers/Link.java +++ b/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/bypasshandlers/Link.java @@ -16,7 +16,9 @@ */ package handlers.bypasshandlers; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.HashSet; +import java.util.Set; + import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.handler.IBypassHandler; import org.l2jmobius.gameserver.model.actor.Creature; @@ -31,67 +33,68 @@ public class Link implements IBypassHandler "Link" }; - private static final String[] VALID_LINKS = + private static final Set VALID_LINKS = new HashSet<>(); + static { - "common/attribute_info.htm", - "common/augmentation_01.htm", - "common/augmentation_02.htm", - "common/augmentation_exchange.htm", - "common/crafting_01.htm", - "common/crafting_02.htm", - "common/crafting_03.htm", - "common/cursed_to_unidentified.htm", - "common/duals_01.htm", - "common/duals_02.htm", - "common/duals_03.htm", - "common/g_cube_warehouse001.htm", - "common/skill_enchant_help.htm", - "common/skill_enchant_help_01.htm", - "common/skill_enchant_help_02.htm", - "common/skill_enchant_help_03.htm", - "common/smelting_trade001.htm", - "common/weapon_sa_01.htm", - "common/welcomeback002.htm", - "common/welcomeback003.htm", - "default/BlessingOfProtection.htm", - "default/SupportMagic.htm", - "default/SupportMagicServitor.htm", - "fisherman/exchange_old_items.htm", - "fisherman/fish_appearance_exchange.htm", - "fisherman/fishing_manual001.htm", - "fisherman/fishing_manual002.htm", - "fisherman/fishing_manual003.htm", - "fisherman/fishing_manual004.htm", - "fisherman/fishing_manual008.htm", - "fisherman/fishing_manual009.htm", - "fisherman/fishing_manual010.htm", - "fortress/foreman.htm", - "guard/kamaloka_help.htm", - "guard/kamaloka_level.htm", - "petmanager/evolve.htm", - "petmanager/exchange.htm", - "petmanager/instructions.htm", - "teleporter/separatedsoul.htm", - "warehouse/clanwh.htm", - "warehouse/privatewh.htm", + VALID_LINKS.add("common/attribute_info.htm"); + VALID_LINKS.add("common/augmentation_01.htm"); + VALID_LINKS.add("common/augmentation_02.htm"); + VALID_LINKS.add("common/augmentation_exchange.htm"); + VALID_LINKS.add("common/crafting_01.htm"); + VALID_LINKS.add("common/crafting_02.htm"); + VALID_LINKS.add("common/crafting_03.htm"); + VALID_LINKS.add("common/cursed_to_unidentified.htm"); + VALID_LINKS.add("common/duals_01.htm"); + VALID_LINKS.add("common/duals_02.htm"); + VALID_LINKS.add("common/duals_03.htm"); + VALID_LINKS.add("common/g_cube_warehouse001.htm"); + VALID_LINKS.add("common/skill_enchant_help.htm"); + VALID_LINKS.add("common/skill_enchant_help_01.htm"); + VALID_LINKS.add("common/skill_enchant_help_02.htm"); + VALID_LINKS.add("common/skill_enchant_help_03.htm"); + VALID_LINKS.add("common/smelting_trade001.htm"); + VALID_LINKS.add("common/weapon_sa_01.htm"); + VALID_LINKS.add("common/welcomeback002.htm"); + VALID_LINKS.add("common/welcomeback003.htm"); + VALID_LINKS.add("default/BlessingOfProtection.htm"); + VALID_LINKS.add("default/SupportMagic.htm"); + VALID_LINKS.add("default/SupportMagicServitor.htm"); + VALID_LINKS.add("fisherman/exchange_old_items.htm"); + VALID_LINKS.add("fisherman/fish_appearance_exchange.htm"); + VALID_LINKS.add("fisherman/fishing_manual001.htm"); + VALID_LINKS.add("fisherman/fishing_manual002.htm"); + VALID_LINKS.add("fisherman/fishing_manual003.htm"); + VALID_LINKS.add("fisherman/fishing_manual004.htm"); + VALID_LINKS.add("fisherman/fishing_manual008.htm"); + VALID_LINKS.add("fisherman/fishing_manual009.htm"); + VALID_LINKS.add("fisherman/fishing_manual010.htm"); + VALID_LINKS.add("fortress/foreman.htm"); + VALID_LINKS.add("guard/kamaloka_help.htm"); + VALID_LINKS.add("guard/kamaloka_level.htm"); + VALID_LINKS.add("petmanager/evolve.htm"); + VALID_LINKS.add("petmanager/exchange.htm"); + VALID_LINKS.add("petmanager/instructions.htm"); + VALID_LINKS.add("teleporter/separatedsoul.htm"); + VALID_LINKS.add("warehouse/clanwh.htm"); + VALID_LINKS.add("warehouse/privatewh.htm"); // Quests - "teleporter/30006.htm", - "teleporter/30006-Q561.htm", - "teleporter/30006-Q561-1.htm", - "teleporter/30006-Q561-2.htm", - "teleporter/30134.htm", - "teleporter/30134-Q562.htm", - "teleporter/30134-Q562-1.htm", - "teleporter/30134-Q562-2.htm", - "teleporter/30256.htm", - "teleporter/30256-Q562.htm", - "teleporter/30256-Q562-1.htm", - "teleporter/30256-Q562-2.htm", - "teleporter/30848.htm", - "teleporter/30848-Q561-Q562.htm", - "teleporter/30848-Q561-Q562-1.htm", - "teleporter/30848-Q561-Q562-2.htm", - }; + VALID_LINKS.add("teleporter/30006.htm"); + VALID_LINKS.add("teleporter/30006-Q561.htm"); + VALID_LINKS.add("teleporter/30006-Q561-1.htm"); + VALID_LINKS.add("teleporter/30006-Q561-2.htm"); + VALID_LINKS.add("teleporter/30134.htm"); + VALID_LINKS.add("teleporter/30134-Q562.htm"); + VALID_LINKS.add("teleporter/30134-Q562-1.htm"); + VALID_LINKS.add("teleporter/30134-Q562-2.htm"); + VALID_LINKS.add("teleporter/30256.htm"); + VALID_LINKS.add("teleporter/30256-Q562.htm"); + VALID_LINKS.add("teleporter/30256-Q562-1.htm"); + VALID_LINKS.add("teleporter/30256-Q562-2.htm"); + VALID_LINKS.add("teleporter/30848.htm"); + VALID_LINKS.add("teleporter/30848-Q561-Q562.htm"); + VALID_LINKS.add("teleporter/30848-Q561-Q562-1.htm"); + VALID_LINKS.add("teleporter/30848-Q561-Q562-2.htm"); + } @Override public boolean useBypass(String command, Player player, Creature target) @@ -109,12 +112,13 @@ public class Link implements IBypassHandler return false; } - String content = CommonUtil.contains(VALID_LINKS, htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; + String content = VALID_LINKS.contains(htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; // Precaution. if (htmlPath.startsWith("teleporter/") && !(player.getTarget() instanceof Teleporter)) { content = null; } + final NpcHtmlMessage html = new NpcHtmlMessage(target != null ? target.getObjectId() : 0); if (content != null) { diff --git a/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java b/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java index 6ff583ebec..a60d57f8f4 100644 --- a/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java +++ b/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java @@ -16,8 +16,9 @@ */ package handlers.dailymissionhandlers; -import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.Config; import org.l2jmobius.gameserver.enums.DailyMissionStatus; @@ -41,7 +42,7 @@ public class MonsterDailyMissionHandler extends AbstractDailyMissionHandler private final int _amount; private final int _minLevel; private final int _maxLevel; - private final List _ids = new ArrayList<>(); + private final Set _ids = new HashSet<>(); public MonsterDailyMissionHandler(DailyMissionDataHolder holder) { diff --git a/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/itemhandlers/PetFood.java b/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/itemhandlers/PetFood.java index 3c5572d4ec..8b908ea095 100644 --- a/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/itemhandlers/PetFood.java +++ b/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/itemhandlers/PetFood.java @@ -17,6 +17,7 @@ package handlers.itemhandlers; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.PetDataTable; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -79,7 +80,7 @@ public class PetFood implements IItemHandler final Player player = activeChar.getActingPlayer(); if (player.isMounted()) { - final List foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); + final Set foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); if (foodIds.contains(item.getId()) && player.destroyItem("Consume", item.getObjectId(), 1, null, false)) { player.broadcastPacket(new MagicSkillUse(player, player, skillId, skillLevel, 0, 0)); diff --git a/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java b/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java index 2ad282f683..99f45fbb41 100644 --- a/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java +++ b/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.ClanHallData; import org.l2jmobius.gameserver.model.StatSet; @@ -32,12 +33,12 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpCheckResidenceSkillCondition implements ISkillCondition { - private final List _residencesId; + private final Set _residencesId = new HashSet<>(); private final boolean _isWithin; public OpCheckResidenceSkillCondition(StatSet params) { - _residencesId = params.getList("residencesId", Integer.class); + _residencesId.addAll(params.getList("residencesId", Integer.class)); _isWithin = params.getBoolean("isWithin"); } diff --git a/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java b/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java index fc2934423b..4a8282d988 100644 --- a/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java +++ b/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java @@ -16,9 +16,9 @@ */ package handlers.skillconditionhandlers; -import java.util.ArrayList; -import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -28,18 +28,18 @@ import org.l2jmobius.gameserver.model.skill.ISkillCondition; import org.l2jmobius.gameserver.model.skill.Skill; /** - * @author UnAfraid + * @author UnAfraid, Mobius */ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition { - private final List _npcIds = new ArrayList<>(); + private final Set _npcIds = new HashSet<>(); public OpNeedSummonOrPetSkillCondition(StatSet params) { - final List npcIds = params.getList("npcIds", String.class); + final List npcIds = params.getList("npcIds", Integer.class); if (npcIds != null) { - npcIds.stream().map(Integer::valueOf).forEach(_npcIds::add); + _npcIds.addAll(npcIds); } } @@ -47,7 +47,19 @@ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition public boolean canUse(Creature caster, Skill skill, WorldObject target) { final Summon pet = caster.getPet(); - final Collection summons = caster.getServitors().values(); - return ((pet != null) && _npcIds.stream().anyMatch(npcId -> npcId == pet.getId())) || summons.stream().anyMatch(summon -> _npcIds.contains(summon.getId())); + if ((pet != null) && _npcIds.contains(pet.getId())) + { + return true; + } + + for (Summon summon : caster.getServitors().values()) + { + if (_npcIds.contains(summon.getId())) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java b/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java index 8541bc62b4..ef81b291d4 100644 --- a/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java +++ b/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,11 +30,11 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetDoorSkillCondition implements ISkillCondition { - private final List _doorIds; + private final Set _doorIds = new HashSet<>(); public OpTargetDoorSkillCondition(StatSet params) { - _doorIds = params.getList("doorIds", Integer.class); + _doorIds.addAll(params.getList("doorIds", Integer.class)); } @Override diff --git a/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java b/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java index 3ce4145703..0ccd571e19 100644 --- a/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java +++ b/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,17 +30,17 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetNpcSkillCondition implements ISkillCondition { - private final List _npcId; + private final Set _npcIds = new HashSet<>(); public OpTargetNpcSkillCondition(StatSet params) { - _npcId = params.getList("npcIds", Integer.class); + _npcIds.addAll(params.getList("npcIds", Integer.class)); } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget(); - return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId()); + return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcIds.contains(actualTarget.getId()); } } diff --git a/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/instances/AbstractInstance.java b/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/instances/AbstractInstance.java index 973aff5e7b..1cd85f15bd 100644 --- a/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/instances/AbstractInstance.java +++ b/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/instances/AbstractInstance.java @@ -16,9 +16,10 @@ */ package instances; +import java.util.HashSet; import java.util.List; +import java.util.Set; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.enums.InstanceReenterType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.instancemanager.InstanceManager; @@ -40,25 +41,29 @@ import ai.AbstractNpcAI; */ public abstract class AbstractInstance extends AbstractNpcAI { - private final int[] _templateIds; + private final Set _templateIds = new HashSet<>(); - public AbstractInstance(int... templateId) + public AbstractInstance(int... templateIds) { - if (templateId.length == 0) + if (templateIds.length == 0) { throw new IllegalStateException("No template ids were provided!"); } - _templateIds = templateId; + + for (int templateId : templateIds) + { + _templateIds.add(templateId); + } } - public int[] getTemplateId() + public Set getTemplateId() { return _templateIds; } public boolean isInInstance(Instance instance) { - return (instance != null) && CommonUtil.contains(_templateIds, instance.getTemplateId()); + return (instance != null) && _templateIds.contains(instance.getTemplateId()); } /** diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/Config.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/Config.java index 304524aeb8..a91529dc86 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/Config.java @@ -287,7 +287,7 @@ public class Config public static boolean AUTO_LOOT_SLOT_LIMIT; public static int LOOT_RAIDS_PRIVILEGE_INTERVAL; public static int LOOT_RAIDS_PRIVILEGE_CC_SIZE; - public static List AUTO_LOOT_ITEM_IDS; + public static Set AUTO_LOOT_ITEM_IDS; public static boolean ENABLE_KEYBOARD_MOVEMENT; public static int UNSTUCK_INTERVAL; public static int TELEPORT_WATCHDOG_TIMEOUT; @@ -455,7 +455,7 @@ public class Config public static boolean ALLOW_DISCARDITEM; public static int AUTODESTROY_ITEM_AFTER; public static int HERB_AUTO_DESTROY_TIME; - public static List LIST_PROTECTED_ITEMS; + public static Set LIST_PROTECTED_ITEMS; public static boolean DATABASE_CLEAN_UP; public static int CHAR_DATA_STORE_INTERVAL; public static int CLAN_VARIABLES_STORE_INTERVAL; @@ -548,7 +548,7 @@ public class Config public static boolean ALT_OLY_LOG_FIGHTS; public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS; public static boolean ALT_OLY_ANNOUNCE_GAMES; - public static List LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(); + public static Set LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(); public static int ALT_OLY_WEAPON_ENCHANT_LIMIT; public static int ALT_OLY_ARMOR_ENCHANT_LIMIT; public static int ALT_OLY_WAIT_TIME; @@ -1234,9 +1234,9 @@ public class Config public static int AUTO_CP_PERCENTAGE; public static int AUTO_HP_PERCENTAGE; public static int AUTO_MP_PERCENTAGE; - public static List AUTO_CP_ITEM_IDS; - public static List AUTO_HP_ITEM_IDS; - public static List AUTO_MP_ITEM_IDS; + public static Set AUTO_CP_ITEM_IDS; + public static Set AUTO_HP_ITEM_IDS; + public static Set AUTO_MP_ITEM_IDS; public static boolean CUSTOM_STARTING_LOC; public static int CUSTOM_STARTING_LOC_X; public static int CUSTOM_STARTING_LOC_Y; @@ -1246,7 +1246,7 @@ public class Config public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; public static int MOB_MIN_SPAWN_RANGE; public static int MOB_MAX_SPAWN_RANGE; - public static List MOBS_LIST_NOT_RANDOM; + public static Set MOBS_LIST_NOT_RANDOM; public static boolean FREE_JUMPS_FOR_ALL; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; @@ -1265,7 +1265,7 @@ public class Config public static boolean COMMUNITY_PREMIUM_SYSTEM_ENABLED; public static int COMMUNITY_PREMIUM_COIN_ID; public static int COMMUNITY_PREMIUM_PRICE_PER_DAY; - public static List COMMUNITY_AVAILABLE_BUFFS; + public static Set COMMUNITY_AVAILABLE_BUFFS; public static Map COMMUNITY_AVAILABLE_TELEPORTS; public static boolean CUSTOM_DEPOSITABLE_ENABLED; public static boolean CUSTOM_DEPOSITABLE_QUEST_ITEMS; @@ -1937,7 +1937,7 @@ public class Config LOOT_RAIDS_PRIVILEGE_INTERVAL = characterConfig.getInt("RaidLootRightsInterval", 900) * 1000; LOOT_RAIDS_PRIVILEGE_CC_SIZE = characterConfig.getInt("RaidLootRightsCCSize", 45); final String[] autoLootItemIds = characterConfig.getString("AutoLootItemIds", "0").split(","); - AUTO_LOOT_ITEM_IDS = new ArrayList<>(autoLootItemIds.length); + AUTO_LOOT_ITEM_IDS = new HashSet<>(autoLootItemIds.length); for (String item : autoLootItemIds) { Integer itm = 0; @@ -2056,7 +2056,7 @@ public class Config AUTODESTROY_ITEM_AFTER = generalConfig.getInt("AutoDestroyDroppedItemAfter", 600); HERB_AUTO_DESTROY_TIME = generalConfig.getInt("AutoDestroyHerbTime", 60) * 1000; final String[] split = generalConfig.getString("ListOfProtectedItems", "0").split(","); - LIST_PROTECTED_ITEMS = new ArrayList<>(split.length); + LIST_PROTECTED_ITEMS = new HashSet<>(split.length); for (String id : split) { LIST_PROTECTED_ITEMS.add(Integer.parseInt(id)); @@ -2454,7 +2454,7 @@ public class Config if (!olyRestrictedItems.isEmpty()) { final String[] olyRestrictedItemsSplit = olyRestrictedItems.split(","); - LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(olyRestrictedItemsSplit.length); + LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(olyRestrictedItemsSplit.length); for (String id : olyRestrictedItemsSplit) { LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id)); @@ -2615,17 +2615,17 @@ public class Config AUTO_CP_PERCENTAGE = autoPotionsConfig.getInt("AutoCpPercentage", 70); AUTO_HP_PERCENTAGE = autoPotionsConfig.getInt("AutoHpPercentage", 70); AUTO_MP_PERCENTAGE = autoPotionsConfig.getInt("AutoMpPercentage", 70); - AUTO_CP_ITEM_IDS = new ArrayList<>(); + AUTO_CP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoCpItemIds", "0").split(",")) { AUTO_CP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_HP_ITEM_IDS = new ArrayList<>(); + AUTO_HP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoHpItemIds", "0").split(",")) { AUTO_HP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_MP_ITEM_IDS = new ArrayList<>(); + AUTO_MP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoMpItemIds", "0").split(",")) { AUTO_MP_ITEM_IDS.add(Integer.parseInt(s)); @@ -3236,7 +3236,7 @@ public class Config COMMUNITY_PREMIUM_COIN_ID = communityBoardConfig.getInt("CommunityPremiumBuyCoinId", 57); COMMUNITY_PREMIUM_PRICE_PER_DAY = communityBoardConfig.getInt("CommunityPremiumPricePerDay", 1000000); final String[] allowedBuffs = communityBoardConfig.getString("CommunityAvailableBuffs", "").split(","); - COMMUNITY_AVAILABLE_BUFFS = new ArrayList<>(allowedBuffs.length); + COMMUNITY_AVAILABLE_BUFFS = new HashSet<>(allowedBuffs.length); for (String s : allowedBuffs) { COMMUNITY_AVAILABLE_BUFFS.add(Integer.parseInt(s)); @@ -3543,7 +3543,7 @@ public class Config if (ENABLE_RANDOM_MONSTER_SPAWNS) { final String[] mobsIds = randomSpawnsConfig.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); - MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + MOBS_LIST_NOT_RANDOM = new HashSet<>(mobsIds.length); for (String id : mobsIds) { MOBS_LIST_NOT_RANDOM.add(Integer.parseInt(id)); diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java index d6e0183c6f..c3977185b4 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java @@ -202,8 +202,7 @@ public class ClanHallData implements IXmlReader final Door door = DoorData.getInstance().getDoor(doorId); for (ClanHall ch : _clanHalls.values()) { - final List doors = ch.getDoors(); - if ((doors != null) && doors.contains(door)) + if (ch.getDoors().contains(door)) { return ch; } diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java index 6aa0a1fdde..fb395b9e2d 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java @@ -17,10 +17,10 @@ package org.l2jmobius.gameserver.data.xml; import java.io.File; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -42,7 +42,7 @@ public class FakePlayerData implements IXmlReader private final Map _fakePlayerInfos = new HashMap<>(); private final Map _fakePlayerNames = new HashMap<>(); private final Map _fakePlayerIds = new HashMap<>(); - private final List _talkableFakePlayerNames = new ArrayList<>(); + private final Set _talkableFakePlayerNames = new HashSet<>(); protected FakePlayerData() { diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java index d335b95954..1122d7b9ba 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java @@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -49,7 +51,7 @@ import org.l2jmobius.gameserver.util.Util; public class SellBuffsManager implements IXmlReader { private static final Logger LOGGER = Logger.getLogger(SellBuffsManager.class.getName()); - private static final List ALLOWED_BUFFS = new ArrayList<>(); + private static final Set ALLOWED_BUFFS = new HashSet<>(); private static final String HTML_FOLDER = "data/html/mods/SellBuffs/"; protected SellBuffsManager() @@ -76,11 +78,7 @@ public class SellBuffsManager implements IXmlReader { final Element elem = (Element) node.item(i); final int skillId = Integer.parseInt(elem.getAttribute("id")); - - if (!ALLOWED_BUFFS.contains(skillId)) - { - ALLOWED_BUFFS.add(skillId); - } + ALLOWED_BUFFS.add(skillId); } } diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java index b10f75ef3d..1e45a21319 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java @@ -19,8 +19,10 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; @@ -67,7 +69,7 @@ public class WalkingManager implements IXmlReader public static final byte REPEAT_TELE_FIRST = 2; public static final byte REPEAT_RANDOM = 3; - private final List _targetedNpcIds = new ArrayList<>(); + private final Set _targetedNpcIds = new HashSet<>(); private final Map _routes = new HashMap<>(); // all available routes private final Map _activeRoutes = new HashMap<>(); // each record represents NPC, moving by predefined route from _routes, and moving progress private final Map _routesToAttach = new HashMap<>(); // each record represents NPC and all available routes for it diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/BlockList.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/BlockList.java index 1af9941ed5..9ac6266e22 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/BlockList.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/BlockList.java @@ -19,9 +19,9 @@ package org.l2jmobius.gameserver.model; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -36,10 +36,11 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; public class BlockList { private static final Logger LOGGER = Logger.getLogger(BlockList.class.getName()); - private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); + + private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); private final Player _owner; - private List _blockList; + private Set _blockList; public BlockList(Player owner) { @@ -68,9 +69,9 @@ public class BlockList OFFLINE_LIST.put(_owner.getObjectId(), _blockList); } - private static List loadList(int objId) + private static Set loadList(int objId) { - final List list = new ArrayList<>(); + final Set list = new HashSet<>(); try (Connection con = DatabaseFactory.getConnection(); PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1")) { @@ -158,7 +159,7 @@ public class BlockList _owner.setMessageRefusal(value); } - private List getBlockList() + private Set getBlockList() { return _blockList; } diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/PetData.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/PetData.java index b534c21f36..231b85e85f 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/PetData.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/PetData.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; import org.l2jmobius.gameserver.model.holders.SkillHolder; @@ -40,7 +42,7 @@ public class PetData private int _minLevel = Byte.MAX_VALUE; private int _maxLevel = 0; private boolean _syncLevel = false; - private final List _food = new ArrayList<>(); + private final Set _food = new HashSet<>(); public PetData(int npcId, int itemId) { @@ -133,7 +135,7 @@ public class PetData /** * @return the pet's food list. */ - public List getFood() + public Set getFood() { return _food; } diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/SkillLearn.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/SkillLearn.java index a69d30f105..3d5704b5f2 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/SkillLearn.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/SkillLearn.java @@ -16,9 +16,8 @@ */ package org.l2jmobius.gameserver.model; -import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashSet; -import java.util.List; import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -40,12 +39,12 @@ public class SkillLearn private final int _getDualClassLevel; private final boolean _autoGet; private final long _levelUpSp; - private final List _requiredItems = new ArrayList<>(); - private final List _races = new ArrayList<>(); - private final List _preReqSkills = new ArrayList<>(); + private final Set _requiredItems = new HashSet<>(1); + private final Set _races = EnumSet.noneOf(Race.class); + private final Set _preReqSkills = new HashSet<>(1); private SocialClass _socialClass; private final boolean _residenceSkill; - private final List _residenceIds = new ArrayList<>(); + private final Set _residenceIds = new HashSet<>(1); private final boolean _learnedByNpc; private final boolean _learnedByFS; private final Set _removeSkills = new HashSet<>(1); @@ -133,9 +132,9 @@ public class SkillLearn } /** - * @return the list with the item holders required to acquire this skill. + * @return the set with the item holders required to acquire this skill. */ - public List getRequiredItems() + public Set getRequiredItems() { return _requiredItems; } @@ -150,9 +149,9 @@ public class SkillLearn } /** - * @return a list with the races that can acquire this skill. + * @return a set with the races that can acquire this skill. */ - public List getRaces() + public Set getRaces() { return _races; } @@ -167,9 +166,9 @@ public class SkillLearn } /** - * @return the list of skill holders required to acquire this skill. + * @return the set of skill holders required to acquire this skill. */ - public List getPreReqSkills() + public Set getPreReqSkills() { return _preReqSkills; } @@ -212,9 +211,9 @@ public class SkillLearn } /** - * @return a list with the Ids where this skill is available. + * @return a set with the Ids where this skill is available. */ - public List getResidenceIds() + public Set getResidenceIds() { return _residenceIds; } diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java index 76d810a2d9..3b04eafa72 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java @@ -22,7 +22,6 @@ import java.sql.ResultSet; import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.List; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; @@ -153,7 +152,7 @@ public class Pet extends Summon broadcastStatusUpdate(); - final List foodIds = getPetData().getFood(); + final Set foodIds = getPetData().getFood(); if (foodIds.isEmpty()) { if (isUncontrollable()) diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java index 11efe435d8..1ed0ee81a4 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java @@ -16,8 +16,8 @@ */ package org.l2jmobius.gameserver.model.actor.instance; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import org.l2jmobius.commons.threads.ThreadPool; @@ -57,7 +57,7 @@ public class Trap extends Npc private boolean _isTriggered; private final int _lifeTime; private Player _owner; - private final List _playersWhoDetectedMe = new ArrayList<>(); + private final Set _playersWhoDetectedMe = new HashSet<>(); private final SkillHolder _skill; private int _remainingTime; // Tasks diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java index 71ef076212..3ba8c20a9b 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor.tasks.player; -import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -69,11 +69,12 @@ public class PetFeedTask implements Runnable _player.sendPacket(SystemMessageId.YOU_ARE_OUT_OF_FEED_MOUNT_STATUS_CANCELED); } - final List foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); + final Set foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); if (foodIds.isEmpty()) { return; } + Item food = null; for (int id : foodIds) { diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java index 50d2a821c3..2611b5f121 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.actor.Creature; @@ -29,9 +29,9 @@ import org.l2jmobius.gameserver.model.zone.ZoneType; */ public class ConditionPlayerInsideZoneId extends Condition { - private final List _zones; + private final Set _zones; - public ConditionPlayerInsideZoneId(List zones) + public ConditionPlayerInsideZoneId(Set zones) { _zones = zones; } diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java index c15065eca2..d644f663f5 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Player; @@ -29,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerInstanceId extends Condition { - private final List _instanceIds; + private final Set _instanceIds; /** * Instantiates a new condition player instance id. * @param instanceIds the instance ids */ - public ConditionPlayerInstanceId(List instanceIds) + public ConditionPlayerInstanceId(Set instanceIds) { _instanceIds = instanceIds; } diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java index 14d61089ed..7c375ec45e 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -28,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerRace extends Condition { - private final Race[] _races; + private final Set _races; /** * Instantiates a new condition player race. * @param races the list containing the allowed races. */ - public ConditionPlayerRace(Race[] races) + public ConditionPlayerRace(Set races) { _races = races; } @@ -46,6 +47,6 @@ public class ConditionPlayerRace extends Condition { return false; } - return CommonUtil.contains(_races, effector.getActingPlayer().getRace()); + return _races.contains(effector.getActingPlayer().getRace()); } } diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java index 0f54766571..0b326e3f40 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId())) + if (_npcIds.contains(target.getId())) { existNpc = true; break; diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java index c5c9b5ff0e..db64b6bd7b 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromSummonedNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromSummonedNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromSummonedNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromSummonedNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId()) && (effector == target.getSummoner())) + if (_npcIds.contains(target.getId()) && (effector == target.getSummoner())) { existNpc = true; break; diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java index a3fb0f5374..a47b4b4983 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetClassIdRestriction extends Condition { - private final List _classIds; + private final Set _classIds; /** * Instantiates a new condition target class id restriction. * @param classId the class id */ - public ConditionTargetClassIdRestriction(List classId) + public ConditionTargetClassIdRestriction(Set classId) { _classIds = classId; } diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java index 82b1bd5877..9bb694f4ef 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetNpcId extends Condition { - private final List _npcIds; + private final Set _npcIds; /** * Instantiates a new condition target npc id. * @param npcIds the npc ids */ - public ConditionTargetNpcId(List npcIds) + public ConditionTargetNpcId(Set npcIds) { _npcIds = npcIds; } diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java index f26329bc21..5c86f26ae5 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.holders; -import java.util.Collection; +import java.util.Set; /** * @author Mobius @@ -25,9 +25,9 @@ public class EventDropHolder extends DropHolder { private final int _minLevel; private final int _maxLevel; - private final Collection _monsterIds; + private final Set _monsterIds; - public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Collection monsterIds) + public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Set monsterIds) { super(null, itemId, min, max, chance); _minLevel = minLevel; @@ -45,7 +45,7 @@ public class EventDropHolder extends DropHolder return _maxLevel; } - public Collection getMonsterIds() + public Set getMonsterIds() { return _monsterIds; } diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/item/Henna.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/item/Henna.java index af805ac1bc..6c2c9feea3 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/item/Henna.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/item/Henna.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model.item; import java.util.ArrayList; import java.util.EnumMap; +import java.util.EnumSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.enums.ClassId; import org.l2jmobius.gameserver.model.StatSet; @@ -42,7 +44,7 @@ public class Henna private final int _cancelCount; private final int _duration; private final List _skills; - private final List _wearClass; + private final Set _wearClass; public Henna(StatSet set) { @@ -63,7 +65,7 @@ public class Henna _cancelCount = set.getInt("cancel_count"); _duration = set.getInt("duration", -1); _skills = new ArrayList<>(); - _wearClass = new ArrayList<>(); + _wearClass = EnumSet.noneOf(ClassId.class); } /** @@ -159,7 +161,7 @@ public class Henna /** * @return the list with the allowed classes to wear this dye. */ - public List getAllowedWearClass() + public Set getAllowedWearClass() { return _wearClass; } diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java index d74b1218d3..5d694e5169 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java @@ -17,9 +17,10 @@ package org.l2jmobius.gameserver.model.item.appearance; import java.time.Duration; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.enums.Race; @@ -47,12 +48,12 @@ public class AppearanceStone private final ArmorType _armorType; private final AppearanceHandType _handType; private final AppearanceMagicType _magicType; - private List _crystalTypes; - private List _targetTypes; - private List _bodyParts; - private List _races; - private List _racesNot; - private List _allVisualIds; + private Set _crystalTypes; + private Set _targetTypes; + private Set _bodyParts; + private Set _races; + private Set _racesNot; + private Set _allVisualIds; public AppearanceStone(StatSet set) { @@ -172,35 +173,35 @@ public class AppearanceStone { if (_crystalTypes == null) { - _crystalTypes = new ArrayList<>(); + _crystalTypes = EnumSet.noneOf(CrystalType.class); } _crystalTypes.add(type); } - public List getCrystalTypes() + public Set getCrystalTypes() { - return _crystalTypes != null ? _crystalTypes : Collections.emptyList(); + return _crystalTypes != null ? _crystalTypes : Collections.emptySet(); } public void addTargetType(AppearanceTargetType type) { if (_targetTypes == null) { - _targetTypes = new ArrayList<>(); + _targetTypes = EnumSet.noneOf(AppearanceTargetType.class); } _targetTypes.add(type); } - public List getTargetTypes() + public Set getTargetTypes() { - return _targetTypes != null ? _targetTypes : Collections.emptyList(); + return _targetTypes != null ? _targetTypes : Collections.emptySet(); } public void addBodyPart(long part) { if (_bodyParts == null) { - _bodyParts = new ArrayList<>(); + _bodyParts = new HashSet<>(); } _bodyParts.add(part); } @@ -209,47 +210,47 @@ public class AppearanceStone { if (_allVisualIds == null) { - _allVisualIds = new ArrayList<>(); + _allVisualIds = new HashSet<>(); } _allVisualIds.add(appearanceHolder); } - public List getVisualIds() + public Set getVisualIds() { - return _allVisualIds != null ? _allVisualIds : Collections.emptyList(); + return _allVisualIds != null ? _allVisualIds : Collections.emptySet(); } - public List getBodyParts() + public Set getBodyParts() { - return _bodyParts != null ? _bodyParts : Collections.emptyList(); + return _bodyParts != null ? _bodyParts : Collections.emptySet(); } public void addRace(Race race) { if (_races == null) { - _races = new ArrayList<>(); + _races = EnumSet.noneOf(Race.class); } _races.add(race); } - public List getRaces() + public Set getRaces() { - return _races != null ? _races : Collections.emptyList(); + return _races != null ? _races : Collections.emptySet(); } public void addRaceNot(Race race) { if (_racesNot == null) { - _racesNot = new ArrayList<>(); + _racesNot = EnumSet.noneOf(Race.class); } _racesNot.add(race); } - public List getRacesNot() + public Set getRacesNot() { - return _racesNot != null ? _racesNot : Collections.emptyList(); + return _racesNot != null ? _racesNot : Collections.emptySet(); } /** @@ -302,7 +303,7 @@ public class AppearanceStone { // Seems like in retail item with already changed appearance, can be changed again without being restored. - final AppearanceTargetType targetType = getTargetTypes().get(0); + final AppearanceTargetType targetType = getTargetTypes().stream().findFirst().get(); switch (targetType) { case NONE: diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java index c21f776020..9af155da21 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java @@ -16,16 +16,16 @@ */ package org.l2jmobius.gameserver.model.item.enchant; +import java.util.EnumSet; +import java.util.Set; import java.util.logging.Logger; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.item.ItemTemplate; import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.model.item.type.CrystalType; import org.l2jmobius.gameserver.model.item.type.EtcItemType; -import org.l2jmobius.gameserver.model.item.type.ItemType; /** * @author UnAfraid @@ -34,28 +34,29 @@ public abstract class AbstractEnchantItem { protected static final Logger LOGGER = Logger.getLogger(AbstractEnchantItem.class.getName()); - private static final ItemType[] ENCHANT_TYPES = new ItemType[] + private static final Set ENCHANT_TYPES = EnumSet.noneOf(EtcItemType.class); + static { - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM, - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP, - EtcItemType.BLESS_ENCHT_AM, - EtcItemType.BLESS_ENCHT_AM_DOWN, - EtcItemType.BLESS_ENCHT_WP, - EtcItemType.ENCHT_AM, - EtcItemType.ENCHT_WP, - EtcItemType.ENCHT_WP_DOWN, - EtcItemType.ENCHT_AM_DOWN, - EtcItemType.GIANT_ENCHT_AM, - EtcItemType.GIANT_ENCHT_WP, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - }; + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP_DOWN); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + } private final int _id; private final CrystalType _grade; @@ -73,7 +74,7 @@ public abstract class AbstractEnchantItem { throw new NullPointerException(); } - else if (!CommonUtil.contains(ENCHANT_TYPES, getItem().getItemType())) + else if (!ENCHANT_TYPES.contains(getItem().getItemType())) { throw new IllegalAccessError(); } diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java index 5ba6755084..18508d0145 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java @@ -24,8 +24,10 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Set; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -184,7 +186,7 @@ public class LongTimeEvent extends Quest final Node maxLevelNode = d.getAttributes().getNamedItem("maxLevel"); final int maxLevel = maxLevelNode == null ? Integer.MAX_VALUE : Integer.parseInt(maxLevelNode.getNodeValue()); final Node monsterIdsNode = d.getAttributes().getNamedItem("monsterIds"); - final List monsterIds = new ArrayList<>(); + final Set monsterIds = new HashSet<>(); if (monsterIdsNode != null) { for (String id : monsterIdsNode.getNodeValue().split(",")) diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/residences/ClanHall.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/residences/ClanHall.java index 0c0a529077..fcc850371b 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/residences/ClanHall.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/residences/ClanHall.java @@ -23,7 +23,9 @@ import java.sql.SQLException; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -61,9 +63,9 @@ public class ClanHall extends AbstractResidence private final int _minBid; final int _lease; private final int _deposit; - private final List _npcs; - private final List _doors; - private final List _teleports; + private final Set _npcs = new HashSet<>(); + private final Set _doors = new HashSet<>(); + private final Set _teleports = new HashSet<>(); private final Location _ownerLocation; private final Location _banishLocation; // Dynamic parameters @@ -85,9 +87,21 @@ public class ClanHall extends AbstractResidence _minBid = params.getInt("minBid"); _lease = params.getInt("lease"); _deposit = params.getInt("deposit"); - _npcs = params.getList("npcList", Integer.class); - _doors = params.getList("doorList", Door.class); - _teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + final List npcs = params.getList("npcList", Integer.class); + if (npcs != null) + { + _npcs.addAll(npcs); + } + final List doors = params.getList("doorList", Door.class); + if (doors != null) + { + _doors.addAll(doors); + } + final List teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + if (teleports != null) + { + _teleports.addAll(teleports); + } _ownerLocation = params.getLocation("owner_loc"); _banishLocation = params.getLocation("banish_loc"); // Set dynamic parameters (from DB) @@ -196,7 +210,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Door} related to this {@link ClanHall}. * @return all {@link Door} related to this {@link ClanHall} */ - public List getDoors() + public Set getDoors() { return _doors; } @@ -205,7 +219,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Npc} related to this {@link ClanHall}. * @return all {@link Npc} related to this {@link ClanHall} */ - public List getNpcs() + public Set getNpcs() { return _npcs; } @@ -324,7 +338,7 @@ public class ClanHall extends AbstractResidence return _banishLocation; } - public List getTeleportList() + public Set getTeleportList() { return _teleports; } diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/siege/Castle.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/siege/Castle.java index 063570e334..27c7525c68 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/siege/Castle.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/siege/Castle.java @@ -21,8 +21,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.Calendar; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -82,7 +84,7 @@ public class Castle extends AbstractResidence private SiegeZone _zone = null; private ResidenceTeleportZone _teleZone; private Clan _formerOwner = null; - private final List _artefacts = new ArrayList<>(1); + private final Set _artefacts = new HashSet<>(1); private final Map _function = new ConcurrentHashMap<>(); private int _ticketBuyCount = 0; private boolean _isFirstMidVictory = false; @@ -1071,7 +1073,7 @@ public class Castle extends AbstractResidence _artefacts.add(artefact); } - public List getArtefacts() + public Set getArtefacts() { return _artefacts; } diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java index 0c79677eae..4ebf954ee5 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.network.serverpackets; -import java.util.List; +import java.util.Set; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.gameserver.data.sql.CharNameTable; @@ -27,19 +27,19 @@ import org.l2jmobius.gameserver.network.OutgoingPackets; */ public class BlockListPacket implements IClientOutgoingPacket { - private final List _playersId; + private final Set _playerIds; - public BlockListPacket(List playersId) + public BlockListPacket(Set playerIds) { - _playersId = playersId; + _playerIds = playerIds; } @Override public boolean write(PacketWriter packet) { OutgoingPackets.BLOCK_LIST.writeId(packet); - packet.writeD(_playersId.size()); - for (int playerId : _playersId) + packet.writeD(_playerIds.size()); + for (int playerId : _playerIds) { packet.writeS(CharNameTable.getInstance().getNameById(playerId)); packet.writeS(""); // memo ? diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java index 8555bb6e86..eb5bfd05d8 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.network.serverpackets; import java.util.List; import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; import org.l2jmobius.commons.network.PacketWriter; @@ -37,7 +38,7 @@ public class ExAcquireSkillInfo implements IClientOutgoingPacket private final int _dualClassLevel; private final long _spCost; private final int _minLevel; - private final List _itemReq; + private final Set _itemReq; private final List _skillRem; /** diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java index 84b5fead76..a163a85735 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java @@ -35,7 +35,7 @@ public class ExChooseShapeShiftingItem implements IClientOutgoingPacket public ExChooseShapeShiftingItem(AppearanceStone stone) { _type = stone.getType(); - _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().get(0); + _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().stream().findFirst().get(); _itemId = stone.getId(); } diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/util/DocumentBase.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/util/DocumentBase.java index 8a8e13d940..c22140b9c4 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/util/DocumentBase.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/util/DocumentBase.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.util; import java.io.File; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -390,12 +391,12 @@ public abstract class DocumentBase case "races": { final String[] racesVal = a.getNodeValue().split(","); - final Race[] races = new Race[racesVal.length]; + final Set races = EnumSet.noneOf(Race.class); for (int r = 0; r < racesVal.length; r++) { if (racesVal[r] != null) { - races[r] = Race.valueOf(racesVal[r]); + races.add(Race.valueOf(racesVal[r])); } } cond = joinAnd(cond, new ConditionPlayerRace(races)); @@ -671,13 +672,13 @@ public abstract class DocumentBase case "instanceid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final ArrayList array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInstanceId(array)); + cond = joinAnd(cond, new ConditionPlayerInstanceId(set)); break; } case "agathionid": @@ -728,10 +729,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -745,10 +746,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -834,13 +835,13 @@ public abstract class DocumentBase case "insidezoneid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInsideZoneId(array)); + cond = joinAnd(cond, new ConditionPlayerInsideZoneId(set)); break; } case "checkabnormal": @@ -961,13 +962,13 @@ public abstract class DocumentBase case "class_id_restriction": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetClassIdRestriction(array)); + cond = joinAnd(cond, new ConditionTargetClassIdRestriction(set)); break; } case "active_effect_id": @@ -1045,13 +1046,13 @@ public abstract class DocumentBase case "npcid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetNpcId(array)); + cond = joinAnd(cond, new ConditionTargetNpcId(set)); break; } case "npctype": diff --git a/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/bypasshandlers/Link.java b/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/bypasshandlers/Link.java index 5bd82b732d..360ed1ae88 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/bypasshandlers/Link.java +++ b/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/bypasshandlers/Link.java @@ -16,7 +16,9 @@ */ package handlers.bypasshandlers; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.HashSet; +import java.util.Set; + import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.handler.IBypassHandler; import org.l2jmobius.gameserver.model.actor.Creature; @@ -31,67 +33,68 @@ public class Link implements IBypassHandler "Link" }; - private static final String[] VALID_LINKS = + private static final Set VALID_LINKS = new HashSet<>(); + static { - "common/attribute_info.htm", - "common/augmentation_01.htm", - "common/augmentation_02.htm", - "common/augmentation_exchange.htm", - "common/crafting_01.htm", - "common/crafting_02.htm", - "common/crafting_03.htm", - "common/cursed_to_unidentified.htm", - "common/duals_01.htm", - "common/duals_02.htm", - "common/duals_03.htm", - "common/g_cube_warehouse001.htm", - "common/skill_enchant_help.htm", - "common/skill_enchant_help_01.htm", - "common/skill_enchant_help_02.htm", - "common/skill_enchant_help_03.htm", - "common/smelting_trade001.htm", - "common/weapon_sa_01.htm", - "common/welcomeback002.htm", - "common/welcomeback003.htm", - "default/BlessingOfProtection.htm", - "default/SupportMagic.htm", - "default/SupportMagicServitor.htm", - "fisherman/exchange_old_items.htm", - "fisherman/fish_appearance_exchange.htm", - "fisherman/fishing_manual001.htm", - "fisherman/fishing_manual002.htm", - "fisherman/fishing_manual003.htm", - "fisherman/fishing_manual004.htm", - "fisherman/fishing_manual008.htm", - "fisherman/fishing_manual009.htm", - "fisherman/fishing_manual010.htm", - "fortress/foreman.htm", - "guard/kamaloka_help.htm", - "guard/kamaloka_level.htm", - "petmanager/evolve.htm", - "petmanager/exchange.htm", - "petmanager/instructions.htm", - "teleporter/separatedsoul.htm", - "warehouse/clanwh.htm", - "warehouse/privatewh.htm", + VALID_LINKS.add("common/attribute_info.htm"); + VALID_LINKS.add("common/augmentation_01.htm"); + VALID_LINKS.add("common/augmentation_02.htm"); + VALID_LINKS.add("common/augmentation_exchange.htm"); + VALID_LINKS.add("common/crafting_01.htm"); + VALID_LINKS.add("common/crafting_02.htm"); + VALID_LINKS.add("common/crafting_03.htm"); + VALID_LINKS.add("common/cursed_to_unidentified.htm"); + VALID_LINKS.add("common/duals_01.htm"); + VALID_LINKS.add("common/duals_02.htm"); + VALID_LINKS.add("common/duals_03.htm"); + VALID_LINKS.add("common/g_cube_warehouse001.htm"); + VALID_LINKS.add("common/skill_enchant_help.htm"); + VALID_LINKS.add("common/skill_enchant_help_01.htm"); + VALID_LINKS.add("common/skill_enchant_help_02.htm"); + VALID_LINKS.add("common/skill_enchant_help_03.htm"); + VALID_LINKS.add("common/smelting_trade001.htm"); + VALID_LINKS.add("common/weapon_sa_01.htm"); + VALID_LINKS.add("common/welcomeback002.htm"); + VALID_LINKS.add("common/welcomeback003.htm"); + VALID_LINKS.add("default/BlessingOfProtection.htm"); + VALID_LINKS.add("default/SupportMagic.htm"); + VALID_LINKS.add("default/SupportMagicServitor.htm"); + VALID_LINKS.add("fisherman/exchange_old_items.htm"); + VALID_LINKS.add("fisherman/fish_appearance_exchange.htm"); + VALID_LINKS.add("fisherman/fishing_manual001.htm"); + VALID_LINKS.add("fisherman/fishing_manual002.htm"); + VALID_LINKS.add("fisherman/fishing_manual003.htm"); + VALID_LINKS.add("fisherman/fishing_manual004.htm"); + VALID_LINKS.add("fisherman/fishing_manual008.htm"); + VALID_LINKS.add("fisherman/fishing_manual009.htm"); + VALID_LINKS.add("fisherman/fishing_manual010.htm"); + VALID_LINKS.add("fortress/foreman.htm"); + VALID_LINKS.add("guard/kamaloka_help.htm"); + VALID_LINKS.add("guard/kamaloka_level.htm"); + VALID_LINKS.add("petmanager/evolve.htm"); + VALID_LINKS.add("petmanager/exchange.htm"); + VALID_LINKS.add("petmanager/instructions.htm"); + VALID_LINKS.add("teleporter/separatedsoul.htm"); + VALID_LINKS.add("warehouse/clanwh.htm"); + VALID_LINKS.add("warehouse/privatewh.htm"); // Quests - "teleporter/30006.htm", - "teleporter/30006-Q561.htm", - "teleporter/30006-Q561-1.htm", - "teleporter/30006-Q561-2.htm", - "teleporter/30134.htm", - "teleporter/30134-Q562.htm", - "teleporter/30134-Q562-1.htm", - "teleporter/30134-Q562-2.htm", - "teleporter/30256.htm", - "teleporter/30256-Q562.htm", - "teleporter/30256-Q562-1.htm", - "teleporter/30256-Q562-2.htm", - "teleporter/30848.htm", - "teleporter/30848-Q561-Q562.htm", - "teleporter/30848-Q561-Q562-1.htm", - "teleporter/30848-Q561-Q562-2.htm", - }; + VALID_LINKS.add("teleporter/30006.htm"); + VALID_LINKS.add("teleporter/30006-Q561.htm"); + VALID_LINKS.add("teleporter/30006-Q561-1.htm"); + VALID_LINKS.add("teleporter/30006-Q561-2.htm"); + VALID_LINKS.add("teleporter/30134.htm"); + VALID_LINKS.add("teleporter/30134-Q562.htm"); + VALID_LINKS.add("teleporter/30134-Q562-1.htm"); + VALID_LINKS.add("teleporter/30134-Q562-2.htm"); + VALID_LINKS.add("teleporter/30256.htm"); + VALID_LINKS.add("teleporter/30256-Q562.htm"); + VALID_LINKS.add("teleporter/30256-Q562-1.htm"); + VALID_LINKS.add("teleporter/30256-Q562-2.htm"); + VALID_LINKS.add("teleporter/30848.htm"); + VALID_LINKS.add("teleporter/30848-Q561-Q562.htm"); + VALID_LINKS.add("teleporter/30848-Q561-Q562-1.htm"); + VALID_LINKS.add("teleporter/30848-Q561-Q562-2.htm"); + } @Override public boolean useBypass(String command, Player player, Creature target) @@ -109,12 +112,13 @@ public class Link implements IBypassHandler return false; } - String content = CommonUtil.contains(VALID_LINKS, htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; + String content = VALID_LINKS.contains(htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; // Precaution. if (htmlPath.startsWith("teleporter/") && !(player.getTarget() instanceof Teleporter)) { content = null; } + final NpcHtmlMessage html = new NpcHtmlMessage(target != null ? target.getObjectId() : 0); if (content != null) { diff --git a/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java b/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java index 6ff583ebec..a60d57f8f4 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java +++ b/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java @@ -16,8 +16,9 @@ */ package handlers.dailymissionhandlers; -import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.Config; import org.l2jmobius.gameserver.enums.DailyMissionStatus; @@ -41,7 +42,7 @@ public class MonsterDailyMissionHandler extends AbstractDailyMissionHandler private final int _amount; private final int _minLevel; private final int _maxLevel; - private final List _ids = new ArrayList<>(); + private final Set _ids = new HashSet<>(); public MonsterDailyMissionHandler(DailyMissionDataHolder holder) { diff --git a/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/itemhandlers/PetFood.java b/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/itemhandlers/PetFood.java index 3c5572d4ec..8b908ea095 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/itemhandlers/PetFood.java +++ b/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/itemhandlers/PetFood.java @@ -17,6 +17,7 @@ package handlers.itemhandlers; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.PetDataTable; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -79,7 +80,7 @@ public class PetFood implements IItemHandler final Player player = activeChar.getActingPlayer(); if (player.isMounted()) { - final List foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); + final Set foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); if (foodIds.contains(item.getId()) && player.destroyItem("Consume", item.getObjectId(), 1, null, false)) { player.broadcastPacket(new MagicSkillUse(player, player, skillId, skillLevel, 0, 0)); diff --git a/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java b/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java index 2ad282f683..99f45fbb41 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java +++ b/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.ClanHallData; import org.l2jmobius.gameserver.model.StatSet; @@ -32,12 +33,12 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpCheckResidenceSkillCondition implements ISkillCondition { - private final List _residencesId; + private final Set _residencesId = new HashSet<>(); private final boolean _isWithin; public OpCheckResidenceSkillCondition(StatSet params) { - _residencesId = params.getList("residencesId", Integer.class); + _residencesId.addAll(params.getList("residencesId", Integer.class)); _isWithin = params.getBoolean("isWithin"); } diff --git a/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java b/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java index fc2934423b..4a8282d988 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java +++ b/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java @@ -16,9 +16,9 @@ */ package handlers.skillconditionhandlers; -import java.util.ArrayList; -import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -28,18 +28,18 @@ import org.l2jmobius.gameserver.model.skill.ISkillCondition; import org.l2jmobius.gameserver.model.skill.Skill; /** - * @author UnAfraid + * @author UnAfraid, Mobius */ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition { - private final List _npcIds = new ArrayList<>(); + private final Set _npcIds = new HashSet<>(); public OpNeedSummonOrPetSkillCondition(StatSet params) { - final List npcIds = params.getList("npcIds", String.class); + final List npcIds = params.getList("npcIds", Integer.class); if (npcIds != null) { - npcIds.stream().map(Integer::valueOf).forEach(_npcIds::add); + _npcIds.addAll(npcIds); } } @@ -47,7 +47,19 @@ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition public boolean canUse(Creature caster, Skill skill, WorldObject target) { final Summon pet = caster.getPet(); - final Collection summons = caster.getServitors().values(); - return ((pet != null) && _npcIds.stream().anyMatch(npcId -> npcId == pet.getId())) || summons.stream().anyMatch(summon -> _npcIds.contains(summon.getId())); + if ((pet != null) && _npcIds.contains(pet.getId())) + { + return true; + } + + for (Summon summon : caster.getServitors().values()) + { + if (_npcIds.contains(summon.getId())) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java b/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java index 8541bc62b4..ef81b291d4 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java +++ b/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,11 +30,11 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetDoorSkillCondition implements ISkillCondition { - private final List _doorIds; + private final Set _doorIds = new HashSet<>(); public OpTargetDoorSkillCondition(StatSet params) { - _doorIds = params.getList("doorIds", Integer.class); + _doorIds.addAll(params.getList("doorIds", Integer.class)); } @Override diff --git a/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java b/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java index 3ce4145703..0ccd571e19 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java +++ b/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,17 +30,17 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetNpcSkillCondition implements ISkillCondition { - private final List _npcId; + private final Set _npcIds = new HashSet<>(); public OpTargetNpcSkillCondition(StatSet params) { - _npcId = params.getList("npcIds", Integer.class); + _npcIds.addAll(params.getList("npcIds", Integer.class)); } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget(); - return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId()); + return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcIds.contains(actualTarget.getId()); } } diff --git a/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/instances/AbstractInstance.java b/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/instances/AbstractInstance.java index d485c2c36d..4a0a3d35d4 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/instances/AbstractInstance.java +++ b/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/instances/AbstractInstance.java @@ -16,9 +16,10 @@ */ package instances; +import java.util.HashSet; import java.util.List; +import java.util.Set; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.enums.InstanceReenterType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.instancemanager.InstanceManager; @@ -40,25 +41,29 @@ import ai.AbstractNpcAI; */ public abstract class AbstractInstance extends AbstractNpcAI { - private final int[] _templateIds; + private final Set _templateIds = new HashSet<>(); - public AbstractInstance(int... templateId) + public AbstractInstance(int... templateIds) { - if (templateId.length == 0) + if (templateIds.length == 0) { throw new IllegalStateException("No template ids were provided!"); } - _templateIds = templateId; + + for (int templateId : templateIds) + { + _templateIds.add(templateId); + } } - public int[] getTemplateId() + public Set getTemplateId() { return _templateIds; } public boolean isInInstance(Instance instance) { - return (instance != null) && CommonUtil.contains(_templateIds, instance.getTemplateId()); + return (instance != null) && _templateIds.contains(instance.getTemplateId()); } /** diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/Config.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/Config.java index 1e961384e4..bd23826014 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/Config.java @@ -287,7 +287,7 @@ public class Config public static boolean AUTO_LOOT_SLOT_LIMIT; public static int LOOT_RAIDS_PRIVILEGE_INTERVAL; public static int LOOT_RAIDS_PRIVILEGE_CC_SIZE; - public static List AUTO_LOOT_ITEM_IDS; + public static Set AUTO_LOOT_ITEM_IDS; public static boolean ENABLE_KEYBOARD_MOVEMENT; public static int UNSTUCK_INTERVAL; public static int TELEPORT_WATCHDOG_TIMEOUT; @@ -455,7 +455,7 @@ public class Config public static boolean ALLOW_DISCARDITEM; public static int AUTODESTROY_ITEM_AFTER; public static int HERB_AUTO_DESTROY_TIME; - public static List LIST_PROTECTED_ITEMS; + public static Set LIST_PROTECTED_ITEMS; public static boolean DATABASE_CLEAN_UP; public static int CHAR_DATA_STORE_INTERVAL; public static int CLAN_VARIABLES_STORE_INTERVAL; @@ -549,7 +549,7 @@ public class Config public static boolean ALT_OLY_LOG_FIGHTS; public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS; public static boolean ALT_OLY_ANNOUNCE_GAMES; - public static List LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(); + public static Set LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(); public static int ALT_OLY_WEAPON_ENCHANT_LIMIT; public static int ALT_OLY_ARMOR_ENCHANT_LIMIT; public static int ALT_OLY_WAIT_TIME; @@ -1242,9 +1242,9 @@ public class Config public static int AUTO_CP_PERCENTAGE; public static int AUTO_HP_PERCENTAGE; public static int AUTO_MP_PERCENTAGE; - public static List AUTO_CP_ITEM_IDS; - public static List AUTO_HP_ITEM_IDS; - public static List AUTO_MP_ITEM_IDS; + public static Set AUTO_CP_ITEM_IDS; + public static Set AUTO_HP_ITEM_IDS; + public static Set AUTO_MP_ITEM_IDS; public static boolean CUSTOM_STARTING_LOC; public static int CUSTOM_STARTING_LOC_X; public static int CUSTOM_STARTING_LOC_Y; @@ -1254,7 +1254,7 @@ public class Config public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; public static int MOB_MIN_SPAWN_RANGE; public static int MOB_MAX_SPAWN_RANGE; - public static List MOBS_LIST_NOT_RANDOM; + public static Set MOBS_LIST_NOT_RANDOM; public static boolean FREE_JUMPS_FOR_ALL; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; @@ -1273,7 +1273,7 @@ public class Config public static boolean COMMUNITY_PREMIUM_SYSTEM_ENABLED; public static int COMMUNITY_PREMIUM_COIN_ID; public static int COMMUNITY_PREMIUM_PRICE_PER_DAY; - public static List COMMUNITY_AVAILABLE_BUFFS; + public static Set COMMUNITY_AVAILABLE_BUFFS; public static Map COMMUNITY_AVAILABLE_TELEPORTS; public static boolean CUSTOM_DEPOSITABLE_ENABLED; public static boolean CUSTOM_DEPOSITABLE_QUEST_ITEMS; @@ -1947,7 +1947,7 @@ public class Config LOOT_RAIDS_PRIVILEGE_INTERVAL = characterConfig.getInt("RaidLootRightsInterval", 900) * 1000; LOOT_RAIDS_PRIVILEGE_CC_SIZE = characterConfig.getInt("RaidLootRightsCCSize", 45); final String[] autoLootItemIds = characterConfig.getString("AutoLootItemIds", "0").split(","); - AUTO_LOOT_ITEM_IDS = new ArrayList<>(autoLootItemIds.length); + AUTO_LOOT_ITEM_IDS = new HashSet<>(autoLootItemIds.length); for (String item : autoLootItemIds) { Integer itm = 0; @@ -2066,7 +2066,7 @@ public class Config AUTODESTROY_ITEM_AFTER = generalConfig.getInt("AutoDestroyDroppedItemAfter", 600); HERB_AUTO_DESTROY_TIME = generalConfig.getInt("AutoDestroyHerbTime", 60) * 1000; final String[] split = generalConfig.getString("ListOfProtectedItems", "0").split(","); - LIST_PROTECTED_ITEMS = new ArrayList<>(split.length); + LIST_PROTECTED_ITEMS = new HashSet<>(split.length); for (String id : split) { LIST_PROTECTED_ITEMS.add(Integer.parseInt(id)); @@ -2470,7 +2470,7 @@ public class Config if (!olyRestrictedItems.isEmpty()) { final String[] olyRestrictedItemsSplit = olyRestrictedItems.split(","); - LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(olyRestrictedItemsSplit.length); + LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(olyRestrictedItemsSplit.length); for (String id : olyRestrictedItemsSplit) { LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id)); @@ -2631,17 +2631,17 @@ public class Config AUTO_CP_PERCENTAGE = autoPotionsConfig.getInt("AutoCpPercentage", 70); AUTO_HP_PERCENTAGE = autoPotionsConfig.getInt("AutoHpPercentage", 70); AUTO_MP_PERCENTAGE = autoPotionsConfig.getInt("AutoMpPercentage", 70); - AUTO_CP_ITEM_IDS = new ArrayList<>(); + AUTO_CP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoCpItemIds", "0").split(",")) { AUTO_CP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_HP_ITEM_IDS = new ArrayList<>(); + AUTO_HP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoHpItemIds", "0").split(",")) { AUTO_HP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_MP_ITEM_IDS = new ArrayList<>(); + AUTO_MP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoMpItemIds", "0").split(",")) { AUTO_MP_ITEM_IDS.add(Integer.parseInt(s)); @@ -3252,7 +3252,7 @@ public class Config COMMUNITY_PREMIUM_COIN_ID = communityBoardConfig.getInt("CommunityPremiumBuyCoinId", 57); COMMUNITY_PREMIUM_PRICE_PER_DAY = communityBoardConfig.getInt("CommunityPremiumPricePerDay", 1000000); final String[] allowedBuffs = communityBoardConfig.getString("CommunityAvailableBuffs", "").split(","); - COMMUNITY_AVAILABLE_BUFFS = new ArrayList<>(allowedBuffs.length); + COMMUNITY_AVAILABLE_BUFFS = new HashSet<>(allowedBuffs.length); for (String s : allowedBuffs) { COMMUNITY_AVAILABLE_BUFFS.add(Integer.parseInt(s)); @@ -3559,7 +3559,7 @@ public class Config if (ENABLE_RANDOM_MONSTER_SPAWNS) { final String[] mobsIds = randomSpawnsConfig.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); - MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + MOBS_LIST_NOT_RANDOM = new HashSet<>(mobsIds.length); for (String id : mobsIds) { MOBS_LIST_NOT_RANDOM.add(Integer.parseInt(id)); diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java index d6e0183c6f..c3977185b4 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java @@ -202,8 +202,7 @@ public class ClanHallData implements IXmlReader final Door door = DoorData.getInstance().getDoor(doorId); for (ClanHall ch : _clanHalls.values()) { - final List doors = ch.getDoors(); - if ((doors != null) && doors.contains(door)) + if (ch.getDoors().contains(door)) { return ch; } diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java index 6aa0a1fdde..fb395b9e2d 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java @@ -17,10 +17,10 @@ package org.l2jmobius.gameserver.data.xml; import java.io.File; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -42,7 +42,7 @@ public class FakePlayerData implements IXmlReader private final Map _fakePlayerInfos = new HashMap<>(); private final Map _fakePlayerNames = new HashMap<>(); private final Map _fakePlayerIds = new HashMap<>(); - private final List _talkableFakePlayerNames = new ArrayList<>(); + private final Set _talkableFakePlayerNames = new HashSet<>(); protected FakePlayerData() { diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java index d335b95954..1122d7b9ba 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java @@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -49,7 +51,7 @@ import org.l2jmobius.gameserver.util.Util; public class SellBuffsManager implements IXmlReader { private static final Logger LOGGER = Logger.getLogger(SellBuffsManager.class.getName()); - private static final List ALLOWED_BUFFS = new ArrayList<>(); + private static final Set ALLOWED_BUFFS = new HashSet<>(); private static final String HTML_FOLDER = "data/html/mods/SellBuffs/"; protected SellBuffsManager() @@ -76,11 +78,7 @@ public class SellBuffsManager implements IXmlReader { final Element elem = (Element) node.item(i); final int skillId = Integer.parseInt(elem.getAttribute("id")); - - if (!ALLOWED_BUFFS.contains(skillId)) - { - ALLOWED_BUFFS.add(skillId); - } + ALLOWED_BUFFS.add(skillId); } } diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java index b10f75ef3d..1e45a21319 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java @@ -19,8 +19,10 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; @@ -67,7 +69,7 @@ public class WalkingManager implements IXmlReader public static final byte REPEAT_TELE_FIRST = 2; public static final byte REPEAT_RANDOM = 3; - private final List _targetedNpcIds = new ArrayList<>(); + private final Set _targetedNpcIds = new HashSet<>(); private final Map _routes = new HashMap<>(); // all available routes private final Map _activeRoutes = new HashMap<>(); // each record represents NPC, moving by predefined route from _routes, and moving progress private final Map _routesToAttach = new HashMap<>(); // each record represents NPC and all available routes for it diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/BlockList.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/BlockList.java index d9ef2e01fb..984f05b22d 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/BlockList.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/BlockList.java @@ -19,9 +19,9 @@ package org.l2jmobius.gameserver.model; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -36,10 +36,11 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; public class BlockList { private static final Logger LOGGER = Logger.getLogger(BlockList.class.getName()); - private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); + + private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); private final Player _owner; - private List _blockList; + private Set _blockList; public BlockList(Player owner) { @@ -68,9 +69,9 @@ public class BlockList OFFLINE_LIST.put(_owner.getObjectId(), _blockList); } - private static List loadList(int objId) + private static Set loadList(int objId) { - final List list = new ArrayList<>(); + final Set list = new HashSet<>(); try (Connection con = DatabaseFactory.getConnection(); PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1")) { @@ -158,7 +159,7 @@ public class BlockList _owner.setMessageRefusal(value); } - private List getBlockList() + private Set getBlockList() { return _blockList; } diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/PetData.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/PetData.java index b534c21f36..231b85e85f 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/PetData.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/PetData.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; import org.l2jmobius.gameserver.model.holders.SkillHolder; @@ -40,7 +42,7 @@ public class PetData private int _minLevel = Byte.MAX_VALUE; private int _maxLevel = 0; private boolean _syncLevel = false; - private final List _food = new ArrayList<>(); + private final Set _food = new HashSet<>(); public PetData(int npcId, int itemId) { @@ -133,7 +135,7 @@ public class PetData /** * @return the pet's food list. */ - public List getFood() + public Set getFood() { return _food; } diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/SkillLearn.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/SkillLearn.java index a69d30f105..3d5704b5f2 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/SkillLearn.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/SkillLearn.java @@ -16,9 +16,8 @@ */ package org.l2jmobius.gameserver.model; -import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashSet; -import java.util.List; import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -40,12 +39,12 @@ public class SkillLearn private final int _getDualClassLevel; private final boolean _autoGet; private final long _levelUpSp; - private final List _requiredItems = new ArrayList<>(); - private final List _races = new ArrayList<>(); - private final List _preReqSkills = new ArrayList<>(); + private final Set _requiredItems = new HashSet<>(1); + private final Set _races = EnumSet.noneOf(Race.class); + private final Set _preReqSkills = new HashSet<>(1); private SocialClass _socialClass; private final boolean _residenceSkill; - private final List _residenceIds = new ArrayList<>(); + private final Set _residenceIds = new HashSet<>(1); private final boolean _learnedByNpc; private final boolean _learnedByFS; private final Set _removeSkills = new HashSet<>(1); @@ -133,9 +132,9 @@ public class SkillLearn } /** - * @return the list with the item holders required to acquire this skill. + * @return the set with the item holders required to acquire this skill. */ - public List getRequiredItems() + public Set getRequiredItems() { return _requiredItems; } @@ -150,9 +149,9 @@ public class SkillLearn } /** - * @return a list with the races that can acquire this skill. + * @return a set with the races that can acquire this skill. */ - public List getRaces() + public Set getRaces() { return _races; } @@ -167,9 +166,9 @@ public class SkillLearn } /** - * @return the list of skill holders required to acquire this skill. + * @return the set of skill holders required to acquire this skill. */ - public List getPreReqSkills() + public Set getPreReqSkills() { return _preReqSkills; } @@ -212,9 +211,9 @@ public class SkillLearn } /** - * @return a list with the Ids where this skill is available. + * @return a set with the Ids where this skill is available. */ - public List getResidenceIds() + public Set getResidenceIds() { return _residenceIds; } diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java index 76d810a2d9..3b04eafa72 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java @@ -22,7 +22,6 @@ import java.sql.ResultSet; import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.List; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; @@ -153,7 +152,7 @@ public class Pet extends Summon broadcastStatusUpdate(); - final List foodIds = getPetData().getFood(); + final Set foodIds = getPetData().getFood(); if (foodIds.isEmpty()) { if (isUncontrollable()) diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java index 11efe435d8..1ed0ee81a4 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java @@ -16,8 +16,8 @@ */ package org.l2jmobius.gameserver.model.actor.instance; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import org.l2jmobius.commons.threads.ThreadPool; @@ -57,7 +57,7 @@ public class Trap extends Npc private boolean _isTriggered; private final int _lifeTime; private Player _owner; - private final List _playersWhoDetectedMe = new ArrayList<>(); + private final Set _playersWhoDetectedMe = new HashSet<>(); private final SkillHolder _skill; private int _remainingTime; // Tasks diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java index 71ef076212..3ba8c20a9b 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor.tasks.player; -import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -69,11 +69,12 @@ public class PetFeedTask implements Runnable _player.sendPacket(SystemMessageId.YOU_ARE_OUT_OF_FEED_MOUNT_STATUS_CANCELED); } - final List foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); + final Set foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); if (foodIds.isEmpty()) { return; } + Item food = null; for (int id : foodIds) { diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java index 50d2a821c3..2611b5f121 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.actor.Creature; @@ -29,9 +29,9 @@ import org.l2jmobius.gameserver.model.zone.ZoneType; */ public class ConditionPlayerInsideZoneId extends Condition { - private final List _zones; + private final Set _zones; - public ConditionPlayerInsideZoneId(List zones) + public ConditionPlayerInsideZoneId(Set zones) { _zones = zones; } diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java index c15065eca2..d644f663f5 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Player; @@ -29,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerInstanceId extends Condition { - private final List _instanceIds; + private final Set _instanceIds; /** * Instantiates a new condition player instance id. * @param instanceIds the instance ids */ - public ConditionPlayerInstanceId(List instanceIds) + public ConditionPlayerInstanceId(Set instanceIds) { _instanceIds = instanceIds; } diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java index 14d61089ed..7c375ec45e 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -28,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerRace extends Condition { - private final Race[] _races; + private final Set _races; /** * Instantiates a new condition player race. * @param races the list containing the allowed races. */ - public ConditionPlayerRace(Race[] races) + public ConditionPlayerRace(Set races) { _races = races; } @@ -46,6 +47,6 @@ public class ConditionPlayerRace extends Condition { return false; } - return CommonUtil.contains(_races, effector.getActingPlayer().getRace()); + return _races.contains(effector.getActingPlayer().getRace()); } } diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java index 0f54766571..0b326e3f40 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId())) + if (_npcIds.contains(target.getId())) { existNpc = true; break; diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java index c5c9b5ff0e..db64b6bd7b 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromSummonedNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromSummonedNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromSummonedNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromSummonedNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId()) && (effector == target.getSummoner())) + if (_npcIds.contains(target.getId()) && (effector == target.getSummoner())) { existNpc = true; break; diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java index a3fb0f5374..a47b4b4983 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetClassIdRestriction extends Condition { - private final List _classIds; + private final Set _classIds; /** * Instantiates a new condition target class id restriction. * @param classId the class id */ - public ConditionTargetClassIdRestriction(List classId) + public ConditionTargetClassIdRestriction(Set classId) { _classIds = classId; } diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java index 82b1bd5877..9bb694f4ef 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetNpcId extends Condition { - private final List _npcIds; + private final Set _npcIds; /** * Instantiates a new condition target npc id. * @param npcIds the npc ids */ - public ConditionTargetNpcId(List npcIds) + public ConditionTargetNpcId(Set npcIds) { _npcIds = npcIds; } diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java index f26329bc21..5c86f26ae5 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.holders; -import java.util.Collection; +import java.util.Set; /** * @author Mobius @@ -25,9 +25,9 @@ public class EventDropHolder extends DropHolder { private final int _minLevel; private final int _maxLevel; - private final Collection _monsterIds; + private final Set _monsterIds; - public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Collection monsterIds) + public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Set monsterIds) { super(null, itemId, min, max, chance); _minLevel = minLevel; @@ -45,7 +45,7 @@ public class EventDropHolder extends DropHolder return _maxLevel; } - public Collection getMonsterIds() + public Set getMonsterIds() { return _monsterIds; } diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/item/Henna.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/item/Henna.java index af805ac1bc..6c2c9feea3 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/item/Henna.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/item/Henna.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model.item; import java.util.ArrayList; import java.util.EnumMap; +import java.util.EnumSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.enums.ClassId; import org.l2jmobius.gameserver.model.StatSet; @@ -42,7 +44,7 @@ public class Henna private final int _cancelCount; private final int _duration; private final List _skills; - private final List _wearClass; + private final Set _wearClass; public Henna(StatSet set) { @@ -63,7 +65,7 @@ public class Henna _cancelCount = set.getInt("cancel_count"); _duration = set.getInt("duration", -1); _skills = new ArrayList<>(); - _wearClass = new ArrayList<>(); + _wearClass = EnumSet.noneOf(ClassId.class); } /** @@ -159,7 +161,7 @@ public class Henna /** * @return the list with the allowed classes to wear this dye. */ - public List getAllowedWearClass() + public Set getAllowedWearClass() { return _wearClass; } diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java index d74b1218d3..5d694e5169 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java @@ -17,9 +17,10 @@ package org.l2jmobius.gameserver.model.item.appearance; import java.time.Duration; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.enums.Race; @@ -47,12 +48,12 @@ public class AppearanceStone private final ArmorType _armorType; private final AppearanceHandType _handType; private final AppearanceMagicType _magicType; - private List _crystalTypes; - private List _targetTypes; - private List _bodyParts; - private List _races; - private List _racesNot; - private List _allVisualIds; + private Set _crystalTypes; + private Set _targetTypes; + private Set _bodyParts; + private Set _races; + private Set _racesNot; + private Set _allVisualIds; public AppearanceStone(StatSet set) { @@ -172,35 +173,35 @@ public class AppearanceStone { if (_crystalTypes == null) { - _crystalTypes = new ArrayList<>(); + _crystalTypes = EnumSet.noneOf(CrystalType.class); } _crystalTypes.add(type); } - public List getCrystalTypes() + public Set getCrystalTypes() { - return _crystalTypes != null ? _crystalTypes : Collections.emptyList(); + return _crystalTypes != null ? _crystalTypes : Collections.emptySet(); } public void addTargetType(AppearanceTargetType type) { if (_targetTypes == null) { - _targetTypes = new ArrayList<>(); + _targetTypes = EnumSet.noneOf(AppearanceTargetType.class); } _targetTypes.add(type); } - public List getTargetTypes() + public Set getTargetTypes() { - return _targetTypes != null ? _targetTypes : Collections.emptyList(); + return _targetTypes != null ? _targetTypes : Collections.emptySet(); } public void addBodyPart(long part) { if (_bodyParts == null) { - _bodyParts = new ArrayList<>(); + _bodyParts = new HashSet<>(); } _bodyParts.add(part); } @@ -209,47 +210,47 @@ public class AppearanceStone { if (_allVisualIds == null) { - _allVisualIds = new ArrayList<>(); + _allVisualIds = new HashSet<>(); } _allVisualIds.add(appearanceHolder); } - public List getVisualIds() + public Set getVisualIds() { - return _allVisualIds != null ? _allVisualIds : Collections.emptyList(); + return _allVisualIds != null ? _allVisualIds : Collections.emptySet(); } - public List getBodyParts() + public Set getBodyParts() { - return _bodyParts != null ? _bodyParts : Collections.emptyList(); + return _bodyParts != null ? _bodyParts : Collections.emptySet(); } public void addRace(Race race) { if (_races == null) { - _races = new ArrayList<>(); + _races = EnumSet.noneOf(Race.class); } _races.add(race); } - public List getRaces() + public Set getRaces() { - return _races != null ? _races : Collections.emptyList(); + return _races != null ? _races : Collections.emptySet(); } public void addRaceNot(Race race) { if (_racesNot == null) { - _racesNot = new ArrayList<>(); + _racesNot = EnumSet.noneOf(Race.class); } _racesNot.add(race); } - public List getRacesNot() + public Set getRacesNot() { - return _racesNot != null ? _racesNot : Collections.emptyList(); + return _racesNot != null ? _racesNot : Collections.emptySet(); } /** @@ -302,7 +303,7 @@ public class AppearanceStone { // Seems like in retail item with already changed appearance, can be changed again without being restored. - final AppearanceTargetType targetType = getTargetTypes().get(0); + final AppearanceTargetType targetType = getTargetTypes().stream().findFirst().get(); switch (targetType) { case NONE: diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java index c21f776020..9af155da21 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java @@ -16,16 +16,16 @@ */ package org.l2jmobius.gameserver.model.item.enchant; +import java.util.EnumSet; +import java.util.Set; import java.util.logging.Logger; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.item.ItemTemplate; import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.model.item.type.CrystalType; import org.l2jmobius.gameserver.model.item.type.EtcItemType; -import org.l2jmobius.gameserver.model.item.type.ItemType; /** * @author UnAfraid @@ -34,28 +34,29 @@ public abstract class AbstractEnchantItem { protected static final Logger LOGGER = Logger.getLogger(AbstractEnchantItem.class.getName()); - private static final ItemType[] ENCHANT_TYPES = new ItemType[] + private static final Set ENCHANT_TYPES = EnumSet.noneOf(EtcItemType.class); + static { - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM, - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP, - EtcItemType.BLESS_ENCHT_AM, - EtcItemType.BLESS_ENCHT_AM_DOWN, - EtcItemType.BLESS_ENCHT_WP, - EtcItemType.ENCHT_AM, - EtcItemType.ENCHT_WP, - EtcItemType.ENCHT_WP_DOWN, - EtcItemType.ENCHT_AM_DOWN, - EtcItemType.GIANT_ENCHT_AM, - EtcItemType.GIANT_ENCHT_WP, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - }; + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP_DOWN); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + } private final int _id; private final CrystalType _grade; @@ -73,7 +74,7 @@ public abstract class AbstractEnchantItem { throw new NullPointerException(); } - else if (!CommonUtil.contains(ENCHANT_TYPES, getItem().getItemType())) + else if (!ENCHANT_TYPES.contains(getItem().getItemType())) { throw new IllegalAccessError(); } diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java index 5ba6755084..18508d0145 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java @@ -24,8 +24,10 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Set; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -184,7 +186,7 @@ public class LongTimeEvent extends Quest final Node maxLevelNode = d.getAttributes().getNamedItem("maxLevel"); final int maxLevel = maxLevelNode == null ? Integer.MAX_VALUE : Integer.parseInt(maxLevelNode.getNodeValue()); final Node monsterIdsNode = d.getAttributes().getNamedItem("monsterIds"); - final List monsterIds = new ArrayList<>(); + final Set monsterIds = new HashSet<>(); if (monsterIdsNode != null) { for (String id : monsterIdsNode.getNodeValue().split(",")) diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/residences/ClanHall.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/residences/ClanHall.java index 0c0a529077..fcc850371b 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/residences/ClanHall.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/residences/ClanHall.java @@ -23,7 +23,9 @@ import java.sql.SQLException; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -61,9 +63,9 @@ public class ClanHall extends AbstractResidence private final int _minBid; final int _lease; private final int _deposit; - private final List _npcs; - private final List _doors; - private final List _teleports; + private final Set _npcs = new HashSet<>(); + private final Set _doors = new HashSet<>(); + private final Set _teleports = new HashSet<>(); private final Location _ownerLocation; private final Location _banishLocation; // Dynamic parameters @@ -85,9 +87,21 @@ public class ClanHall extends AbstractResidence _minBid = params.getInt("minBid"); _lease = params.getInt("lease"); _deposit = params.getInt("deposit"); - _npcs = params.getList("npcList", Integer.class); - _doors = params.getList("doorList", Door.class); - _teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + final List npcs = params.getList("npcList", Integer.class); + if (npcs != null) + { + _npcs.addAll(npcs); + } + final List doors = params.getList("doorList", Door.class); + if (doors != null) + { + _doors.addAll(doors); + } + final List teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + if (teleports != null) + { + _teleports.addAll(teleports); + } _ownerLocation = params.getLocation("owner_loc"); _banishLocation = params.getLocation("banish_loc"); // Set dynamic parameters (from DB) @@ -196,7 +210,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Door} related to this {@link ClanHall}. * @return all {@link Door} related to this {@link ClanHall} */ - public List getDoors() + public Set getDoors() { return _doors; } @@ -205,7 +219,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Npc} related to this {@link ClanHall}. * @return all {@link Npc} related to this {@link ClanHall} */ - public List getNpcs() + public Set getNpcs() { return _npcs; } @@ -324,7 +338,7 @@ public class ClanHall extends AbstractResidence return _banishLocation; } - public List getTeleportList() + public Set getTeleportList() { return _teleports; } diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/siege/Castle.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/siege/Castle.java index 063570e334..27c7525c68 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/siege/Castle.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/siege/Castle.java @@ -21,8 +21,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.Calendar; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -82,7 +84,7 @@ public class Castle extends AbstractResidence private SiegeZone _zone = null; private ResidenceTeleportZone _teleZone; private Clan _formerOwner = null; - private final List _artefacts = new ArrayList<>(1); + private final Set _artefacts = new HashSet<>(1); private final Map _function = new ConcurrentHashMap<>(); private int _ticketBuyCount = 0; private boolean _isFirstMidVictory = false; @@ -1071,7 +1073,7 @@ public class Castle extends AbstractResidence _artefacts.add(artefact); } - public List getArtefacts() + public Set getArtefacts() { return _artefacts; } diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java index 0c79677eae..4ebf954ee5 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.network.serverpackets; -import java.util.List; +import java.util.Set; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.gameserver.data.sql.CharNameTable; @@ -27,19 +27,19 @@ import org.l2jmobius.gameserver.network.OutgoingPackets; */ public class BlockListPacket implements IClientOutgoingPacket { - private final List _playersId; + private final Set _playerIds; - public BlockListPacket(List playersId) + public BlockListPacket(Set playerIds) { - _playersId = playersId; + _playerIds = playerIds; } @Override public boolean write(PacketWriter packet) { OutgoingPackets.BLOCK_LIST.writeId(packet); - packet.writeD(_playersId.size()); - for (int playerId : _playersId) + packet.writeD(_playerIds.size()); + for (int playerId : _playerIds) { packet.writeS(CharNameTable.getInstance().getNameById(playerId)); packet.writeS(""); // memo ? diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java index 8555bb6e86..eb5bfd05d8 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.network.serverpackets; import java.util.List; import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; import org.l2jmobius.commons.network.PacketWriter; @@ -37,7 +38,7 @@ public class ExAcquireSkillInfo implements IClientOutgoingPacket private final int _dualClassLevel; private final long _spCost; private final int _minLevel; - private final List _itemReq; + private final Set _itemReq; private final List _skillRem; /** diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java index 84b5fead76..a163a85735 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java @@ -35,7 +35,7 @@ public class ExChooseShapeShiftingItem implements IClientOutgoingPacket public ExChooseShapeShiftingItem(AppearanceStone stone) { _type = stone.getType(); - _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().get(0); + _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().stream().findFirst().get(); _itemId = stone.getId(); } diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/DocumentBase.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/DocumentBase.java index 66c6fe17a5..72d5f2ab75 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/DocumentBase.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/DocumentBase.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.util; import java.io.File; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -391,12 +392,12 @@ public abstract class DocumentBase case "races": { final String[] racesVal = a.getNodeValue().split(","); - final Race[] races = new Race[racesVal.length]; + final Set races = EnumSet.noneOf(Race.class); for (int r = 0; r < racesVal.length; r++) { if (racesVal[r] != null) { - races[r] = Race.valueOf(racesVal[r]); + races.add(Race.valueOf(racesVal[r])); } } cond = joinAnd(cond, new ConditionPlayerRace(races)); @@ -672,13 +673,13 @@ public abstract class DocumentBase case "instanceid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final ArrayList array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInstanceId(array)); + cond = joinAnd(cond, new ConditionPlayerInstanceId(set)); break; } case "agathionid": @@ -729,10 +730,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -746,10 +747,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -835,13 +836,13 @@ public abstract class DocumentBase case "insidezoneid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInsideZoneId(array)); + cond = joinAnd(cond, new ConditionPlayerInsideZoneId(set)); break; } case "checkabnormal": @@ -968,13 +969,13 @@ public abstract class DocumentBase case "class_id_restriction": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetClassIdRestriction(array)); + cond = joinAnd(cond, new ConditionTargetClassIdRestriction(set)); break; } case "active_effect_id": @@ -1052,13 +1053,13 @@ public abstract class DocumentBase case "npcid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetNpcId(array)); + cond = joinAnd(cond, new ConditionTargetNpcId(set)); break; } case "npctype": diff --git a/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/bypasshandlers/Link.java b/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/bypasshandlers/Link.java index 1fa74edabd..06390c5abd 100644 --- a/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/bypasshandlers/Link.java +++ b/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/bypasshandlers/Link.java @@ -16,7 +16,9 @@ */ package handlers.bypasshandlers; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.HashSet; +import java.util.Set; + import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.handler.IBypassHandler; import org.l2jmobius.gameserver.model.actor.Creature; @@ -31,52 +33,53 @@ public class Link implements IBypassHandler "Link" }; - private static final String[] VALID_LINKS = + private static final Set VALID_LINKS = new HashSet<>(); + static { - "common/imbue_soul_crystal.htm", - "common/extract_soul_crystal.htm", - "common/attribute_info.htm", - "common/augmentation_01.htm", - "common/augmentation_02.htm", - "common/augmentation_exchange.htm", - "common/crafting_01.htm", - "common/crafting_02.htm", - "common/crafting_03.htm", - "common/cursed_to_unidentified.htm", - "common/duals_01.htm", - "common/duals_02.htm", - "common/duals_03.htm", - "common/g_cube_warehouse001.htm", - "common/skill_enchant_help.htm", - "common/skill_enchant_help_01.htm", - "common/skill_enchant_help_02.htm", - "common/skill_enchant_help_03.htm", - "common/smelting_trade001.htm", - "common/weapon_sa_01.htm", - "common/welcomeback002.htm", - "common/welcomeback003.htm", - "default/BlessingOfProtection.htm", - "default/SupportMagic.htm", - "default/SupportMagicServitor.htm", - "fisherman/exchange_old_items.htm", - "fisherman/fish_appearance_exchange.htm", - "fisherman/fishing_manual001.htm", - "fisherman/fishing_manual002.htm", - "fisherman/fishing_manual003.htm", - "fisherman/fishing_manual004.htm", - "fisherman/fishing_manual008.htm", - "fisherman/fishing_manual009.htm", - "fisherman/fishing_manual010.htm", - "fortress/foreman.htm", - "guard/kamaloka_help.htm", - "guard/kamaloka_level.htm", - "petmanager/evolve.htm", - "petmanager/exchange.htm", - "petmanager/instructions.htm", - "teleporter/separatedsoul.htm", - "warehouse/clanwh.htm", - "warehouse/privatewh.htm", - }; + VALID_LINKS.add("common/imbue_soul_crystal.htm"); + VALID_LINKS.add("common/extract_soul_crystal.htm"); + VALID_LINKS.add("common/attribute_info.htm"); + VALID_LINKS.add("common/augmentation_01.htm"); + VALID_LINKS.add("common/augmentation_02.htm"); + VALID_LINKS.add("common/augmentation_exchange.htm"); + VALID_LINKS.add("common/crafting_01.htm"); + VALID_LINKS.add("common/crafting_02.htm"); + VALID_LINKS.add("common/crafting_03.htm"); + VALID_LINKS.add("common/cursed_to_unidentified.htm"); + VALID_LINKS.add("common/duals_01.htm"); + VALID_LINKS.add("common/duals_02.htm"); + VALID_LINKS.add("common/duals_03.htm"); + VALID_LINKS.add("common/g_cube_warehouse001.htm"); + VALID_LINKS.add("common/skill_enchant_help.htm"); + VALID_LINKS.add("common/skill_enchant_help_01.htm"); + VALID_LINKS.add("common/skill_enchant_help_02.htm"); + VALID_LINKS.add("common/skill_enchant_help_03.htm"); + VALID_LINKS.add("common/smelting_trade001.htm"); + VALID_LINKS.add("common/weapon_sa_01.htm"); + VALID_LINKS.add("common/welcomeback002.htm"); + VALID_LINKS.add("common/welcomeback003.htm"); + VALID_LINKS.add("default/BlessingOfProtection.htm"); + VALID_LINKS.add("default/SupportMagic.htm"); + VALID_LINKS.add("default/SupportMagicServitor.htm"); + VALID_LINKS.add("fisherman/exchange_old_items.htm"); + VALID_LINKS.add("fisherman/fish_appearance_exchange.htm"); + VALID_LINKS.add("fisherman/fishing_manual001.htm"); + VALID_LINKS.add("fisherman/fishing_manual002.htm"); + VALID_LINKS.add("fisherman/fishing_manual003.htm"); + VALID_LINKS.add("fisherman/fishing_manual004.htm"); + VALID_LINKS.add("fisherman/fishing_manual008.htm"); + VALID_LINKS.add("fisherman/fishing_manual009.htm"); + VALID_LINKS.add("fisherman/fishing_manual010.htm"); + VALID_LINKS.add("fortress/foreman.htm"); + VALID_LINKS.add("guard/kamaloka_help.htm"); + VALID_LINKS.add("guard/kamaloka_level.htm"); + VALID_LINKS.add("petmanager/evolve.htm"); + VALID_LINKS.add("petmanager/exchange.htm"); + VALID_LINKS.add("petmanager/instructions.htm"); + VALID_LINKS.add("teleporter/separatedsoul.htm"); + VALID_LINKS.add("warehouse/clanwh.htm"); + VALID_LINKS.add("warehouse/privatewh.htm"); + } @Override public boolean useBypass(String command, Player player, Creature target) @@ -94,12 +97,13 @@ public class Link implements IBypassHandler return false; } - String content = CommonUtil.contains(VALID_LINKS, htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; + String content = VALID_LINKS.contains(htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; // Precaution. if (htmlPath.startsWith("teleporter/") && !(player.getTarget() instanceof Teleporter)) { content = null; } + final NpcHtmlMessage html = new NpcHtmlMessage(target != null ? target.getObjectId() : 0); if (content != null) { diff --git a/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java b/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java index ae22dcd5f9..6a96a47163 100644 --- a/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java +++ b/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java @@ -16,8 +16,9 @@ */ package handlers.dailymissionhandlers; -import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.Config; import org.l2jmobius.gameserver.enums.DailyMissionStatus; @@ -41,7 +42,7 @@ public class MonsterDailyMissionHandler extends AbstractDailyMissionHandler private final int _amount; private final int _minLevel; private final int _maxLevel; - private final List _ids = new ArrayList<>(); + private final Set _ids = new HashSet<>(); public MonsterDailyMissionHandler(DailyMissionDataHolder holder) { diff --git a/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/itemhandlers/PetFood.java b/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/itemhandlers/PetFood.java index 3c5572d4ec..8b908ea095 100644 --- a/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/itemhandlers/PetFood.java +++ b/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/itemhandlers/PetFood.java @@ -17,6 +17,7 @@ package handlers.itemhandlers; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.PetDataTable; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -79,7 +80,7 @@ public class PetFood implements IItemHandler final Player player = activeChar.getActingPlayer(); if (player.isMounted()) { - final List foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); + final Set foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); if (foodIds.contains(item.getId()) && player.destroyItem("Consume", item.getObjectId(), 1, null, false)) { player.broadcastPacket(new MagicSkillUse(player, player, skillId, skillLevel, 0, 0)); diff --git a/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java b/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java index 2ad282f683..99f45fbb41 100644 --- a/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java +++ b/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.ClanHallData; import org.l2jmobius.gameserver.model.StatSet; @@ -32,12 +33,12 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpCheckResidenceSkillCondition implements ISkillCondition { - private final List _residencesId; + private final Set _residencesId = new HashSet<>(); private final boolean _isWithin; public OpCheckResidenceSkillCondition(StatSet params) { - _residencesId = params.getList("residencesId", Integer.class); + _residencesId.addAll(params.getList("residencesId", Integer.class)); _isWithin = params.getBoolean("isWithin"); } diff --git a/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java b/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java index fc2934423b..4a8282d988 100644 --- a/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java +++ b/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java @@ -16,9 +16,9 @@ */ package handlers.skillconditionhandlers; -import java.util.ArrayList; -import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -28,18 +28,18 @@ import org.l2jmobius.gameserver.model.skill.ISkillCondition; import org.l2jmobius.gameserver.model.skill.Skill; /** - * @author UnAfraid + * @author UnAfraid, Mobius */ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition { - private final List _npcIds = new ArrayList<>(); + private final Set _npcIds = new HashSet<>(); public OpNeedSummonOrPetSkillCondition(StatSet params) { - final List npcIds = params.getList("npcIds", String.class); + final List npcIds = params.getList("npcIds", Integer.class); if (npcIds != null) { - npcIds.stream().map(Integer::valueOf).forEach(_npcIds::add); + _npcIds.addAll(npcIds); } } @@ -47,7 +47,19 @@ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition public boolean canUse(Creature caster, Skill skill, WorldObject target) { final Summon pet = caster.getPet(); - final Collection summons = caster.getServitors().values(); - return ((pet != null) && _npcIds.stream().anyMatch(npcId -> npcId == pet.getId())) || summons.stream().anyMatch(summon -> _npcIds.contains(summon.getId())); + if ((pet != null) && _npcIds.contains(pet.getId())) + { + return true; + } + + for (Summon summon : caster.getServitors().values()) + { + if (_npcIds.contains(summon.getId())) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java b/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java index 8541bc62b4..ef81b291d4 100644 --- a/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java +++ b/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,11 +30,11 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetDoorSkillCondition implements ISkillCondition { - private final List _doorIds; + private final Set _doorIds = new HashSet<>(); public OpTargetDoorSkillCondition(StatSet params) { - _doorIds = params.getList("doorIds", Integer.class); + _doorIds.addAll(params.getList("doorIds", Integer.class)); } @Override diff --git a/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java b/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java index 3ce4145703..0ccd571e19 100644 --- a/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java +++ b/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,17 +30,17 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetNpcSkillCondition implements ISkillCondition { - private final List _npcId; + private final Set _npcIds = new HashSet<>(); public OpTargetNpcSkillCondition(StatSet params) { - _npcId = params.getList("npcIds", Integer.class); + _npcIds.addAll(params.getList("npcIds", Integer.class)); } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget(); - return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId()); + return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcIds.contains(actualTarget.getId()); } } diff --git a/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/instances/AbstractInstance.java b/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/instances/AbstractInstance.java index d485c2c36d..4a0a3d35d4 100644 --- a/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/instances/AbstractInstance.java +++ b/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/instances/AbstractInstance.java @@ -16,9 +16,10 @@ */ package instances; +import java.util.HashSet; import java.util.List; +import java.util.Set; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.enums.InstanceReenterType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.instancemanager.InstanceManager; @@ -40,25 +41,29 @@ import ai.AbstractNpcAI; */ public abstract class AbstractInstance extends AbstractNpcAI { - private final int[] _templateIds; + private final Set _templateIds = new HashSet<>(); - public AbstractInstance(int... templateId) + public AbstractInstance(int... templateIds) { - if (templateId.length == 0) + if (templateIds.length == 0) { throw new IllegalStateException("No template ids were provided!"); } - _templateIds = templateId; + + for (int templateId : templateIds) + { + _templateIds.add(templateId); + } } - public int[] getTemplateId() + public Set getTemplateId() { return _templateIds; } public boolean isInInstance(Instance instance) { - return (instance != null) && CommonUtil.contains(_templateIds, instance.getTemplateId()); + return (instance != null) && _templateIds.contains(instance.getTemplateId()); } /** diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/Config.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/Config.java index 519f12c1ef..cde6decb8d 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/Config.java @@ -287,7 +287,7 @@ public class Config public static boolean AUTO_LOOT_SLOT_LIMIT; public static int LOOT_RAIDS_PRIVILEGE_INTERVAL; public static int LOOT_RAIDS_PRIVILEGE_CC_SIZE; - public static List AUTO_LOOT_ITEM_IDS; + public static Set AUTO_LOOT_ITEM_IDS; public static boolean ENABLE_KEYBOARD_MOVEMENT; public static int UNSTUCK_INTERVAL; public static int TELEPORT_WATCHDOG_TIMEOUT; @@ -455,7 +455,7 @@ public class Config public static boolean ALLOW_DISCARDITEM; public static int AUTODESTROY_ITEM_AFTER; public static int HERB_AUTO_DESTROY_TIME; - public static List LIST_PROTECTED_ITEMS; + public static Set LIST_PROTECTED_ITEMS; public static boolean DATABASE_CLEAN_UP; public static int CHAR_DATA_STORE_INTERVAL; public static int CLAN_VARIABLES_STORE_INTERVAL; @@ -546,7 +546,7 @@ public class Config public static boolean ALT_OLY_LOG_FIGHTS; public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS; public static boolean ALT_OLY_ANNOUNCE_GAMES; - public static List LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(); + public static Set LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(); public static int ALT_OLY_WEAPON_ENCHANT_LIMIT; public static int ALT_OLY_ARMOR_ENCHANT_LIMIT; public static int ALT_OLY_WAIT_TIME; @@ -1240,9 +1240,9 @@ public class Config public static int AUTO_CP_PERCENTAGE; public static int AUTO_HP_PERCENTAGE; public static int AUTO_MP_PERCENTAGE; - public static List AUTO_CP_ITEM_IDS; - public static List AUTO_HP_ITEM_IDS; - public static List AUTO_MP_ITEM_IDS; + public static Set AUTO_CP_ITEM_IDS; + public static Set AUTO_HP_ITEM_IDS; + public static Set AUTO_MP_ITEM_IDS; public static boolean CUSTOM_STARTING_LOC; public static int CUSTOM_STARTING_LOC_X; public static int CUSTOM_STARTING_LOC_Y; @@ -1252,7 +1252,7 @@ public class Config public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; public static int MOB_MIN_SPAWN_RANGE; public static int MOB_MAX_SPAWN_RANGE; - public static List MOBS_LIST_NOT_RANDOM; + public static Set MOBS_LIST_NOT_RANDOM; public static boolean FREE_JUMPS_FOR_ALL; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; @@ -1271,7 +1271,7 @@ public class Config public static boolean COMMUNITY_PREMIUM_SYSTEM_ENABLED; public static int COMMUNITY_PREMIUM_COIN_ID; public static int COMMUNITY_PREMIUM_PRICE_PER_DAY; - public static List COMMUNITY_AVAILABLE_BUFFS; + public static Set COMMUNITY_AVAILABLE_BUFFS; public static Map COMMUNITY_AVAILABLE_TELEPORTS; public static boolean CUSTOM_DEPOSITABLE_ENABLED; public static boolean CUSTOM_DEPOSITABLE_QUEST_ITEMS; @@ -1945,7 +1945,7 @@ public class Config LOOT_RAIDS_PRIVILEGE_INTERVAL = characterConfig.getInt("RaidLootRightsInterval", 900) * 1000; LOOT_RAIDS_PRIVILEGE_CC_SIZE = characterConfig.getInt("RaidLootRightsCCSize", 45); final String[] autoLootItemIds = characterConfig.getString("AutoLootItemIds", "0").split(","); - AUTO_LOOT_ITEM_IDS = new ArrayList<>(autoLootItemIds.length); + AUTO_LOOT_ITEM_IDS = new HashSet<>(autoLootItemIds.length); for (String item : autoLootItemIds) { Integer itm = 0; @@ -2065,7 +2065,7 @@ public class Config AUTODESTROY_ITEM_AFTER = generalConfig.getInt("AutoDestroyDroppedItemAfter", 600); HERB_AUTO_DESTROY_TIME = generalConfig.getInt("AutoDestroyHerbTime", 60) * 1000; final String[] split = generalConfig.getString("ListOfProtectedItems", "0").split(","); - LIST_PROTECTED_ITEMS = new ArrayList<>(split.length); + LIST_PROTECTED_ITEMS = new HashSet<>(split.length); for (String id : split) { LIST_PROTECTED_ITEMS.add(Integer.parseInt(id)); @@ -2466,7 +2466,7 @@ public class Config if (!olyRestrictedItems.isEmpty()) { final String[] olyRestrictedItemsSplit = olyRestrictedItems.split(","); - LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(olyRestrictedItemsSplit.length); + LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(olyRestrictedItemsSplit.length); for (String id : olyRestrictedItemsSplit) { LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id)); @@ -2627,17 +2627,17 @@ public class Config AUTO_CP_PERCENTAGE = autoPotionsConfig.getInt("AutoCpPercentage", 70); AUTO_HP_PERCENTAGE = autoPotionsConfig.getInt("AutoHpPercentage", 70); AUTO_MP_PERCENTAGE = autoPotionsConfig.getInt("AutoMpPercentage", 70); - AUTO_CP_ITEM_IDS = new ArrayList<>(); + AUTO_CP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoCpItemIds", "0").split(",")) { AUTO_CP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_HP_ITEM_IDS = new ArrayList<>(); + AUTO_HP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoHpItemIds", "0").split(",")) { AUTO_HP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_MP_ITEM_IDS = new ArrayList<>(); + AUTO_MP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoMpItemIds", "0").split(",")) { AUTO_MP_ITEM_IDS.add(Integer.parseInt(s)); @@ -3248,7 +3248,7 @@ public class Config COMMUNITY_PREMIUM_COIN_ID = communityBoardConfig.getInt("CommunityPremiumBuyCoinId", 57); COMMUNITY_PREMIUM_PRICE_PER_DAY = communityBoardConfig.getInt("CommunityPremiumPricePerDay", 1000000); final String[] allowedBuffs = communityBoardConfig.getString("CommunityAvailableBuffs", "").split(","); - COMMUNITY_AVAILABLE_BUFFS = new ArrayList<>(allowedBuffs.length); + COMMUNITY_AVAILABLE_BUFFS = new HashSet<>(allowedBuffs.length); for (String s : allowedBuffs) { COMMUNITY_AVAILABLE_BUFFS.add(Integer.parseInt(s)); @@ -3555,7 +3555,7 @@ public class Config if (ENABLE_RANDOM_MONSTER_SPAWNS) { final String[] mobsIds = randomSpawnsConfig.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); - MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + MOBS_LIST_NOT_RANDOM = new HashSet<>(mobsIds.length); for (String id : mobsIds) { MOBS_LIST_NOT_RANDOM.add(Integer.parseInt(id)); diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java index d6e0183c6f..c3977185b4 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java @@ -202,8 +202,7 @@ public class ClanHallData implements IXmlReader final Door door = DoorData.getInstance().getDoor(doorId); for (ClanHall ch : _clanHalls.values()) { - final List doors = ch.getDoors(); - if ((doors != null) && doors.contains(door)) + if (ch.getDoors().contains(door)) { return ch; } diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java index 6aa0a1fdde..fb395b9e2d 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java @@ -17,10 +17,10 @@ package org.l2jmobius.gameserver.data.xml; import java.io.File; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -42,7 +42,7 @@ public class FakePlayerData implements IXmlReader private final Map _fakePlayerInfos = new HashMap<>(); private final Map _fakePlayerNames = new HashMap<>(); private final Map _fakePlayerIds = new HashMap<>(); - private final List _talkableFakePlayerNames = new ArrayList<>(); + private final Set _talkableFakePlayerNames = new HashSet<>(); protected FakePlayerData() { diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/data/xml/VariationData.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/data/xml/VariationData.java index c29a10baa2..079f5b3077 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/data/xml/VariationData.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/data/xml/VariationData.java @@ -20,8 +20,10 @@ import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Logger; @@ -114,14 +116,11 @@ public class VariationData implements IXmlReader }); // Support for specific item ids. - final List itemIds = new ArrayList<>(); + final Set itemIds = new HashSet<>(); forEach(categoryNode, "item", optionNode -> { final int itemId = parseInteger(optionNode.getAttributes(), "id"); - if (!itemIds.contains(itemId)) - { - itemIds.add(itemId); - } + itemIds.add(itemId); }); forEach(categoryNode, "items", optionNode -> { @@ -129,10 +128,7 @@ public class VariationData implements IXmlReader final int toId = parseInteger(optionNode.getAttributes(), "to"); for (int id = fromId; id <= toId; id++) { - if (!itemIds.contains(id)) - { - itemIds.add(id); - } + itemIds.add(id); } }); diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java index d335b95954..1122d7b9ba 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java @@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -49,7 +51,7 @@ import org.l2jmobius.gameserver.util.Util; public class SellBuffsManager implements IXmlReader { private static final Logger LOGGER = Logger.getLogger(SellBuffsManager.class.getName()); - private static final List ALLOWED_BUFFS = new ArrayList<>(); + private static final Set ALLOWED_BUFFS = new HashSet<>(); private static final String HTML_FOLDER = "data/html/mods/SellBuffs/"; protected SellBuffsManager() @@ -76,11 +78,7 @@ public class SellBuffsManager implements IXmlReader { final Element elem = (Element) node.item(i); final int skillId = Integer.parseInt(elem.getAttribute("id")); - - if (!ALLOWED_BUFFS.contains(skillId)) - { - ALLOWED_BUFFS.add(skillId); - } + ALLOWED_BUFFS.add(skillId); } } diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java index b10f75ef3d..1e45a21319 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java @@ -19,8 +19,10 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; @@ -67,7 +69,7 @@ public class WalkingManager implements IXmlReader public static final byte REPEAT_TELE_FIRST = 2; public static final byte REPEAT_RANDOM = 3; - private final List _targetedNpcIds = new ArrayList<>(); + private final Set _targetedNpcIds = new HashSet<>(); private final Map _routes = new HashMap<>(); // all available routes private final Map _activeRoutes = new HashMap<>(); // each record represents NPC, moving by predefined route from _routes, and moving progress private final Map _routesToAttach = new HashMap<>(); // each record represents NPC and all available routes for it diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/BlockList.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/BlockList.java index d9ef2e01fb..984f05b22d 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/BlockList.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/BlockList.java @@ -19,9 +19,9 @@ package org.l2jmobius.gameserver.model; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -36,10 +36,11 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; public class BlockList { private static final Logger LOGGER = Logger.getLogger(BlockList.class.getName()); - private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); + + private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); private final Player _owner; - private List _blockList; + private Set _blockList; public BlockList(Player owner) { @@ -68,9 +69,9 @@ public class BlockList OFFLINE_LIST.put(_owner.getObjectId(), _blockList); } - private static List loadList(int objId) + private static Set loadList(int objId) { - final List list = new ArrayList<>(); + final Set list = new HashSet<>(); try (Connection con = DatabaseFactory.getConnection(); PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1")) { @@ -158,7 +159,7 @@ public class BlockList _owner.setMessageRefusal(value); } - private List getBlockList() + private Set getBlockList() { return _blockList; } diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/PetData.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/PetData.java index b534c21f36..231b85e85f 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/PetData.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/PetData.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; import org.l2jmobius.gameserver.model.holders.SkillHolder; @@ -40,7 +42,7 @@ public class PetData private int _minLevel = Byte.MAX_VALUE; private int _maxLevel = 0; private boolean _syncLevel = false; - private final List _food = new ArrayList<>(); + private final Set _food = new HashSet<>(); public PetData(int npcId, int itemId) { @@ -133,7 +135,7 @@ public class PetData /** * @return the pet's food list. */ - public List getFood() + public Set getFood() { return _food; } diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/SkillLearn.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/SkillLearn.java index a69d30f105..3d5704b5f2 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/SkillLearn.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/SkillLearn.java @@ -16,9 +16,8 @@ */ package org.l2jmobius.gameserver.model; -import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashSet; -import java.util.List; import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -40,12 +39,12 @@ public class SkillLearn private final int _getDualClassLevel; private final boolean _autoGet; private final long _levelUpSp; - private final List _requiredItems = new ArrayList<>(); - private final List _races = new ArrayList<>(); - private final List _preReqSkills = new ArrayList<>(); + private final Set _requiredItems = new HashSet<>(1); + private final Set _races = EnumSet.noneOf(Race.class); + private final Set _preReqSkills = new HashSet<>(1); private SocialClass _socialClass; private final boolean _residenceSkill; - private final List _residenceIds = new ArrayList<>(); + private final Set _residenceIds = new HashSet<>(1); private final boolean _learnedByNpc; private final boolean _learnedByFS; private final Set _removeSkills = new HashSet<>(1); @@ -133,9 +132,9 @@ public class SkillLearn } /** - * @return the list with the item holders required to acquire this skill. + * @return the set with the item holders required to acquire this skill. */ - public List getRequiredItems() + public Set getRequiredItems() { return _requiredItems; } @@ -150,9 +149,9 @@ public class SkillLearn } /** - * @return a list with the races that can acquire this skill. + * @return a set with the races that can acquire this skill. */ - public List getRaces() + public Set getRaces() { return _races; } @@ -167,9 +166,9 @@ public class SkillLearn } /** - * @return the list of skill holders required to acquire this skill. + * @return the set of skill holders required to acquire this skill. */ - public List getPreReqSkills() + public Set getPreReqSkills() { return _preReqSkills; } @@ -212,9 +211,9 @@ public class SkillLearn } /** - * @return a list with the Ids where this skill is available. + * @return a set with the Ids where this skill is available. */ - public List getResidenceIds() + public Set getResidenceIds() { return _residenceIds; } diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java index 1dc8499399..f0c453e361 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java @@ -22,7 +22,6 @@ import java.sql.ResultSet; import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.List; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; @@ -153,7 +152,7 @@ public class Pet extends Summon broadcastStatusUpdate(); - final List foodIds = getPetData().getFood(); + final Set foodIds = getPetData().getFood(); if (foodIds.isEmpty()) { if (isUncontrollable()) diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java index 11efe435d8..1ed0ee81a4 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java @@ -16,8 +16,8 @@ */ package org.l2jmobius.gameserver.model.actor.instance; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import org.l2jmobius.commons.threads.ThreadPool; @@ -57,7 +57,7 @@ public class Trap extends Npc private boolean _isTriggered; private final int _lifeTime; private Player _owner; - private final List _playersWhoDetectedMe = new ArrayList<>(); + private final Set _playersWhoDetectedMe = new HashSet<>(); private final SkillHolder _skill; private int _remainingTime; // Tasks diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java index 71ef076212..3ba8c20a9b 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor.tasks.player; -import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -69,11 +69,12 @@ public class PetFeedTask implements Runnable _player.sendPacket(SystemMessageId.YOU_ARE_OUT_OF_FEED_MOUNT_STATUS_CANCELED); } - final List foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); + final Set foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); if (foodIds.isEmpty()) { return; } + Item food = null; for (int id : foodIds) { diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java index 50d2a821c3..2611b5f121 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.actor.Creature; @@ -29,9 +29,9 @@ import org.l2jmobius.gameserver.model.zone.ZoneType; */ public class ConditionPlayerInsideZoneId extends Condition { - private final List _zones; + private final Set _zones; - public ConditionPlayerInsideZoneId(List zones) + public ConditionPlayerInsideZoneId(Set zones) { _zones = zones; } diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java index c15065eca2..d644f663f5 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Player; @@ -29,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerInstanceId extends Condition { - private final List _instanceIds; + private final Set _instanceIds; /** * Instantiates a new condition player instance id. * @param instanceIds the instance ids */ - public ConditionPlayerInstanceId(List instanceIds) + public ConditionPlayerInstanceId(Set instanceIds) { _instanceIds = instanceIds; } diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java index 14d61089ed..7c375ec45e 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -28,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerRace extends Condition { - private final Race[] _races; + private final Set _races; /** * Instantiates a new condition player race. * @param races the list containing the allowed races. */ - public ConditionPlayerRace(Race[] races) + public ConditionPlayerRace(Set races) { _races = races; } @@ -46,6 +47,6 @@ public class ConditionPlayerRace extends Condition { return false; } - return CommonUtil.contains(_races, effector.getActingPlayer().getRace()); + return _races.contains(effector.getActingPlayer().getRace()); } } diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java index 0f54766571..0b326e3f40 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId())) + if (_npcIds.contains(target.getId())) { existNpc = true; break; diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java index c5c9b5ff0e..db64b6bd7b 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromSummonedNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromSummonedNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromSummonedNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromSummonedNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId()) && (effector == target.getSummoner())) + if (_npcIds.contains(target.getId()) && (effector == target.getSummoner())) { existNpc = true; break; diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java index a3fb0f5374..a47b4b4983 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetClassIdRestriction extends Condition { - private final List _classIds; + private final Set _classIds; /** * Instantiates a new condition target class id restriction. * @param classId the class id */ - public ConditionTargetClassIdRestriction(List classId) + public ConditionTargetClassIdRestriction(Set classId) { _classIds = classId; } diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java index 82b1bd5877..9bb694f4ef 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetNpcId extends Condition { - private final List _npcIds; + private final Set _npcIds; /** * Instantiates a new condition target npc id. * @param npcIds the npc ids */ - public ConditionTargetNpcId(List npcIds) + public ConditionTargetNpcId(Set npcIds) { _npcIds = npcIds; } diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java index f26329bc21..5c86f26ae5 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.holders; -import java.util.Collection; +import java.util.Set; /** * @author Mobius @@ -25,9 +25,9 @@ public class EventDropHolder extends DropHolder { private final int _minLevel; private final int _maxLevel; - private final Collection _monsterIds; + private final Set _monsterIds; - public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Collection monsterIds) + public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Set monsterIds) { super(null, itemId, min, max, chance); _minLevel = minLevel; @@ -45,7 +45,7 @@ public class EventDropHolder extends DropHolder return _maxLevel; } - public Collection getMonsterIds() + public Set getMonsterIds() { return _monsterIds; } diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/item/Henna.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/item/Henna.java index af805ac1bc..6c2c9feea3 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/item/Henna.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/item/Henna.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model.item; import java.util.ArrayList; import java.util.EnumMap; +import java.util.EnumSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.enums.ClassId; import org.l2jmobius.gameserver.model.StatSet; @@ -42,7 +44,7 @@ public class Henna private final int _cancelCount; private final int _duration; private final List _skills; - private final List _wearClass; + private final Set _wearClass; public Henna(StatSet set) { @@ -63,7 +65,7 @@ public class Henna _cancelCount = set.getInt("cancel_count"); _duration = set.getInt("duration", -1); _skills = new ArrayList<>(); - _wearClass = new ArrayList<>(); + _wearClass = EnumSet.noneOf(ClassId.class); } /** @@ -159,7 +161,7 @@ public class Henna /** * @return the list with the allowed classes to wear this dye. */ - public List getAllowedWearClass() + public Set getAllowedWearClass() { return _wearClass; } diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java index d74b1218d3..5d694e5169 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java @@ -17,9 +17,10 @@ package org.l2jmobius.gameserver.model.item.appearance; import java.time.Duration; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.enums.Race; @@ -47,12 +48,12 @@ public class AppearanceStone private final ArmorType _armorType; private final AppearanceHandType _handType; private final AppearanceMagicType _magicType; - private List _crystalTypes; - private List _targetTypes; - private List _bodyParts; - private List _races; - private List _racesNot; - private List _allVisualIds; + private Set _crystalTypes; + private Set _targetTypes; + private Set _bodyParts; + private Set _races; + private Set _racesNot; + private Set _allVisualIds; public AppearanceStone(StatSet set) { @@ -172,35 +173,35 @@ public class AppearanceStone { if (_crystalTypes == null) { - _crystalTypes = new ArrayList<>(); + _crystalTypes = EnumSet.noneOf(CrystalType.class); } _crystalTypes.add(type); } - public List getCrystalTypes() + public Set getCrystalTypes() { - return _crystalTypes != null ? _crystalTypes : Collections.emptyList(); + return _crystalTypes != null ? _crystalTypes : Collections.emptySet(); } public void addTargetType(AppearanceTargetType type) { if (_targetTypes == null) { - _targetTypes = new ArrayList<>(); + _targetTypes = EnumSet.noneOf(AppearanceTargetType.class); } _targetTypes.add(type); } - public List getTargetTypes() + public Set getTargetTypes() { - return _targetTypes != null ? _targetTypes : Collections.emptyList(); + return _targetTypes != null ? _targetTypes : Collections.emptySet(); } public void addBodyPart(long part) { if (_bodyParts == null) { - _bodyParts = new ArrayList<>(); + _bodyParts = new HashSet<>(); } _bodyParts.add(part); } @@ -209,47 +210,47 @@ public class AppearanceStone { if (_allVisualIds == null) { - _allVisualIds = new ArrayList<>(); + _allVisualIds = new HashSet<>(); } _allVisualIds.add(appearanceHolder); } - public List getVisualIds() + public Set getVisualIds() { - return _allVisualIds != null ? _allVisualIds : Collections.emptyList(); + return _allVisualIds != null ? _allVisualIds : Collections.emptySet(); } - public List getBodyParts() + public Set getBodyParts() { - return _bodyParts != null ? _bodyParts : Collections.emptyList(); + return _bodyParts != null ? _bodyParts : Collections.emptySet(); } public void addRace(Race race) { if (_races == null) { - _races = new ArrayList<>(); + _races = EnumSet.noneOf(Race.class); } _races.add(race); } - public List getRaces() + public Set getRaces() { - return _races != null ? _races : Collections.emptyList(); + return _races != null ? _races : Collections.emptySet(); } public void addRaceNot(Race race) { if (_racesNot == null) { - _racesNot = new ArrayList<>(); + _racesNot = EnumSet.noneOf(Race.class); } _racesNot.add(race); } - public List getRacesNot() + public Set getRacesNot() { - return _racesNot != null ? _racesNot : Collections.emptyList(); + return _racesNot != null ? _racesNot : Collections.emptySet(); } /** @@ -302,7 +303,7 @@ public class AppearanceStone { // Seems like in retail item with already changed appearance, can be changed again without being restored. - final AppearanceTargetType targetType = getTargetTypes().get(0); + final AppearanceTargetType targetType = getTargetTypes().stream().findFirst().get(); switch (targetType) { case NONE: diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java index c21f776020..9af155da21 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java @@ -16,16 +16,16 @@ */ package org.l2jmobius.gameserver.model.item.enchant; +import java.util.EnumSet; +import java.util.Set; import java.util.logging.Logger; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.item.ItemTemplate; import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.model.item.type.CrystalType; import org.l2jmobius.gameserver.model.item.type.EtcItemType; -import org.l2jmobius.gameserver.model.item.type.ItemType; /** * @author UnAfraid @@ -34,28 +34,29 @@ public abstract class AbstractEnchantItem { protected static final Logger LOGGER = Logger.getLogger(AbstractEnchantItem.class.getName()); - private static final ItemType[] ENCHANT_TYPES = new ItemType[] + private static final Set ENCHANT_TYPES = EnumSet.noneOf(EtcItemType.class); + static { - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM, - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP, - EtcItemType.BLESS_ENCHT_AM, - EtcItemType.BLESS_ENCHT_AM_DOWN, - EtcItemType.BLESS_ENCHT_WP, - EtcItemType.ENCHT_AM, - EtcItemType.ENCHT_WP, - EtcItemType.ENCHT_WP_DOWN, - EtcItemType.ENCHT_AM_DOWN, - EtcItemType.GIANT_ENCHT_AM, - EtcItemType.GIANT_ENCHT_WP, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - }; + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP_DOWN); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + } private final int _id; private final CrystalType _grade; @@ -73,7 +74,7 @@ public abstract class AbstractEnchantItem { throw new NullPointerException(); } - else if (!CommonUtil.contains(ENCHANT_TYPES, getItem().getItemType())) + else if (!ENCHANT_TYPES.contains(getItem().getItemType())) { throw new IllegalAccessError(); } diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/options/OptionDataCategory.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/options/OptionDataCategory.java index dd8d1e4281..4e7856e4a2 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/options/OptionDataCategory.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/options/OptionDataCategory.java @@ -16,9 +16,9 @@ */ package org.l2jmobius.gameserver.model.options; -import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import org.l2jmobius.commons.util.Rnd; @@ -28,10 +28,10 @@ import org.l2jmobius.commons.util.Rnd; public class OptionDataCategory { private final Map _options; - private final List _itemIds; + private final Set _itemIds; private final double _chance; - public OptionDataCategory(Map options, List itemIds, double chance) + public OptionDataCategory(Map options, Set itemIds, double chance) { _options = options; _itemIds = itemIds; @@ -59,7 +59,7 @@ public class OptionDataCategory return result; } - public List getItemIds() + public Set getItemIds() { return _itemIds; } diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java index 5ba6755084..18508d0145 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java @@ -24,8 +24,10 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Set; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -184,7 +186,7 @@ public class LongTimeEvent extends Quest final Node maxLevelNode = d.getAttributes().getNamedItem("maxLevel"); final int maxLevel = maxLevelNode == null ? Integer.MAX_VALUE : Integer.parseInt(maxLevelNode.getNodeValue()); final Node monsterIdsNode = d.getAttributes().getNamedItem("monsterIds"); - final List monsterIds = new ArrayList<>(); + final Set monsterIds = new HashSet<>(); if (monsterIdsNode != null) { for (String id : monsterIdsNode.getNodeValue().split(",")) diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/residences/ClanHall.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/residences/ClanHall.java index 0c0a529077..fcc850371b 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/residences/ClanHall.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/residences/ClanHall.java @@ -23,7 +23,9 @@ import java.sql.SQLException; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -61,9 +63,9 @@ public class ClanHall extends AbstractResidence private final int _minBid; final int _lease; private final int _deposit; - private final List _npcs; - private final List _doors; - private final List _teleports; + private final Set _npcs = new HashSet<>(); + private final Set _doors = new HashSet<>(); + private final Set _teleports = new HashSet<>(); private final Location _ownerLocation; private final Location _banishLocation; // Dynamic parameters @@ -85,9 +87,21 @@ public class ClanHall extends AbstractResidence _minBid = params.getInt("minBid"); _lease = params.getInt("lease"); _deposit = params.getInt("deposit"); - _npcs = params.getList("npcList", Integer.class); - _doors = params.getList("doorList", Door.class); - _teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + final List npcs = params.getList("npcList", Integer.class); + if (npcs != null) + { + _npcs.addAll(npcs); + } + final List doors = params.getList("doorList", Door.class); + if (doors != null) + { + _doors.addAll(doors); + } + final List teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + if (teleports != null) + { + _teleports.addAll(teleports); + } _ownerLocation = params.getLocation("owner_loc"); _banishLocation = params.getLocation("banish_loc"); // Set dynamic parameters (from DB) @@ -196,7 +210,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Door} related to this {@link ClanHall}. * @return all {@link Door} related to this {@link ClanHall} */ - public List getDoors() + public Set getDoors() { return _doors; } @@ -205,7 +219,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Npc} related to this {@link ClanHall}. * @return all {@link Npc} related to this {@link ClanHall} */ - public List getNpcs() + public Set getNpcs() { return _npcs; } @@ -324,7 +338,7 @@ public class ClanHall extends AbstractResidence return _banishLocation; } - public List getTeleportList() + public Set getTeleportList() { return _teleports; } diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/siege/Castle.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/siege/Castle.java index 063570e334..27c7525c68 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/siege/Castle.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/siege/Castle.java @@ -21,8 +21,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.Calendar; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -82,7 +84,7 @@ public class Castle extends AbstractResidence private SiegeZone _zone = null; private ResidenceTeleportZone _teleZone; private Clan _formerOwner = null; - private final List _artefacts = new ArrayList<>(1); + private final Set _artefacts = new HashSet<>(1); private final Map _function = new ConcurrentHashMap<>(); private int _ticketBuyCount = 0; private boolean _isFirstMidVictory = false; @@ -1071,7 +1073,7 @@ public class Castle extends AbstractResidence _artefacts.add(artefact); } - public List getArtefacts() + public Set getArtefacts() { return _artefacts; } diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java index 0c79677eae..4ebf954ee5 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.network.serverpackets; -import java.util.List; +import java.util.Set; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.gameserver.data.sql.CharNameTable; @@ -27,19 +27,19 @@ import org.l2jmobius.gameserver.network.OutgoingPackets; */ public class BlockListPacket implements IClientOutgoingPacket { - private final List _playersId; + private final Set _playerIds; - public BlockListPacket(List playersId) + public BlockListPacket(Set playerIds) { - _playersId = playersId; + _playerIds = playerIds; } @Override public boolean write(PacketWriter packet) { OutgoingPackets.BLOCK_LIST.writeId(packet); - packet.writeD(_playersId.size()); - for (int playerId : _playersId) + packet.writeD(_playerIds.size()); + for (int playerId : _playerIds) { packet.writeS(CharNameTable.getInstance().getNameById(playerId)); packet.writeS(""); // memo ? diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java index 8555bb6e86..eb5bfd05d8 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.network.serverpackets; import java.util.List; import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; import org.l2jmobius.commons.network.PacketWriter; @@ -37,7 +38,7 @@ public class ExAcquireSkillInfo implements IClientOutgoingPacket private final int _dualClassLevel; private final long _spCost; private final int _minLevel; - private final List _itemReq; + private final Set _itemReq; private final List _skillRem; /** diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java index 84b5fead76..a163a85735 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java @@ -35,7 +35,7 @@ public class ExChooseShapeShiftingItem implements IClientOutgoingPacket public ExChooseShapeShiftingItem(AppearanceStone stone) { _type = stone.getType(); - _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().get(0); + _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().stream().findFirst().get(); _itemId = stone.getId(); } diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/util/DocumentBase.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/util/DocumentBase.java index ee1955dcf6..cd6eeb37fb 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/util/DocumentBase.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/util/DocumentBase.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.util; import java.io.File; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -392,12 +393,12 @@ public abstract class DocumentBase case "races": { final String[] racesVal = a.getNodeValue().split(","); - final Race[] races = new Race[racesVal.length]; + final Set races = EnumSet.noneOf(Race.class); for (int r = 0; r < racesVal.length; r++) { if (racesVal[r] != null) { - races[r] = Race.valueOf(racesVal[r]); + races.add(Race.valueOf(racesVal[r])); } } cond = joinAnd(cond, new ConditionPlayerRace(races)); @@ -673,13 +674,13 @@ public abstract class DocumentBase case "instanceid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final ArrayList array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInstanceId(array)); + cond = joinAnd(cond, new ConditionPlayerInstanceId(set)); break; } case "agathionid": @@ -730,10 +731,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -747,10 +748,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -836,13 +837,13 @@ public abstract class DocumentBase case "insidezoneid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInsideZoneId(array)); + cond = joinAnd(cond, new ConditionPlayerInsideZoneId(set)); break; } case "checkabnormal": @@ -975,13 +976,13 @@ public abstract class DocumentBase case "class_id_restriction": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetClassIdRestriction(array)); + cond = joinAnd(cond, new ConditionTargetClassIdRestriction(set)); break; } case "active_effect_id": @@ -1059,13 +1060,13 @@ public abstract class DocumentBase case "npcid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetNpcId(array)); + cond = joinAnd(cond, new ConditionTargetNpcId(set)); break; } case "npctype": diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/bypasshandlers/Link.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/bypasshandlers/Link.java index 1fa74edabd..06390c5abd 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/bypasshandlers/Link.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/bypasshandlers/Link.java @@ -16,7 +16,9 @@ */ package handlers.bypasshandlers; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.HashSet; +import java.util.Set; + import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.handler.IBypassHandler; import org.l2jmobius.gameserver.model.actor.Creature; @@ -31,52 +33,53 @@ public class Link implements IBypassHandler "Link" }; - private static final String[] VALID_LINKS = + private static final Set VALID_LINKS = new HashSet<>(); + static { - "common/imbue_soul_crystal.htm", - "common/extract_soul_crystal.htm", - "common/attribute_info.htm", - "common/augmentation_01.htm", - "common/augmentation_02.htm", - "common/augmentation_exchange.htm", - "common/crafting_01.htm", - "common/crafting_02.htm", - "common/crafting_03.htm", - "common/cursed_to_unidentified.htm", - "common/duals_01.htm", - "common/duals_02.htm", - "common/duals_03.htm", - "common/g_cube_warehouse001.htm", - "common/skill_enchant_help.htm", - "common/skill_enchant_help_01.htm", - "common/skill_enchant_help_02.htm", - "common/skill_enchant_help_03.htm", - "common/smelting_trade001.htm", - "common/weapon_sa_01.htm", - "common/welcomeback002.htm", - "common/welcomeback003.htm", - "default/BlessingOfProtection.htm", - "default/SupportMagic.htm", - "default/SupportMagicServitor.htm", - "fisherman/exchange_old_items.htm", - "fisherman/fish_appearance_exchange.htm", - "fisherman/fishing_manual001.htm", - "fisherman/fishing_manual002.htm", - "fisherman/fishing_manual003.htm", - "fisherman/fishing_manual004.htm", - "fisherman/fishing_manual008.htm", - "fisherman/fishing_manual009.htm", - "fisherman/fishing_manual010.htm", - "fortress/foreman.htm", - "guard/kamaloka_help.htm", - "guard/kamaloka_level.htm", - "petmanager/evolve.htm", - "petmanager/exchange.htm", - "petmanager/instructions.htm", - "teleporter/separatedsoul.htm", - "warehouse/clanwh.htm", - "warehouse/privatewh.htm", - }; + VALID_LINKS.add("common/imbue_soul_crystal.htm"); + VALID_LINKS.add("common/extract_soul_crystal.htm"); + VALID_LINKS.add("common/attribute_info.htm"); + VALID_LINKS.add("common/augmentation_01.htm"); + VALID_LINKS.add("common/augmentation_02.htm"); + VALID_LINKS.add("common/augmentation_exchange.htm"); + VALID_LINKS.add("common/crafting_01.htm"); + VALID_LINKS.add("common/crafting_02.htm"); + VALID_LINKS.add("common/crafting_03.htm"); + VALID_LINKS.add("common/cursed_to_unidentified.htm"); + VALID_LINKS.add("common/duals_01.htm"); + VALID_LINKS.add("common/duals_02.htm"); + VALID_LINKS.add("common/duals_03.htm"); + VALID_LINKS.add("common/g_cube_warehouse001.htm"); + VALID_LINKS.add("common/skill_enchant_help.htm"); + VALID_LINKS.add("common/skill_enchant_help_01.htm"); + VALID_LINKS.add("common/skill_enchant_help_02.htm"); + VALID_LINKS.add("common/skill_enchant_help_03.htm"); + VALID_LINKS.add("common/smelting_trade001.htm"); + VALID_LINKS.add("common/weapon_sa_01.htm"); + VALID_LINKS.add("common/welcomeback002.htm"); + VALID_LINKS.add("common/welcomeback003.htm"); + VALID_LINKS.add("default/BlessingOfProtection.htm"); + VALID_LINKS.add("default/SupportMagic.htm"); + VALID_LINKS.add("default/SupportMagicServitor.htm"); + VALID_LINKS.add("fisherman/exchange_old_items.htm"); + VALID_LINKS.add("fisherman/fish_appearance_exchange.htm"); + VALID_LINKS.add("fisherman/fishing_manual001.htm"); + VALID_LINKS.add("fisherman/fishing_manual002.htm"); + VALID_LINKS.add("fisherman/fishing_manual003.htm"); + VALID_LINKS.add("fisherman/fishing_manual004.htm"); + VALID_LINKS.add("fisherman/fishing_manual008.htm"); + VALID_LINKS.add("fisherman/fishing_manual009.htm"); + VALID_LINKS.add("fisherman/fishing_manual010.htm"); + VALID_LINKS.add("fortress/foreman.htm"); + VALID_LINKS.add("guard/kamaloka_help.htm"); + VALID_LINKS.add("guard/kamaloka_level.htm"); + VALID_LINKS.add("petmanager/evolve.htm"); + VALID_LINKS.add("petmanager/exchange.htm"); + VALID_LINKS.add("petmanager/instructions.htm"); + VALID_LINKS.add("teleporter/separatedsoul.htm"); + VALID_LINKS.add("warehouse/clanwh.htm"); + VALID_LINKS.add("warehouse/privatewh.htm"); + } @Override public boolean useBypass(String command, Player player, Creature target) @@ -94,12 +97,13 @@ public class Link implements IBypassHandler return false; } - String content = CommonUtil.contains(VALID_LINKS, htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; + String content = VALID_LINKS.contains(htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; // Precaution. if (htmlPath.startsWith("teleporter/") && !(player.getTarget() instanceof Teleporter)) { content = null; } + final NpcHtmlMessage html = new NpcHtmlMessage(target != null ? target.getObjectId() : 0); if (content != null) { diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java index ae22dcd5f9..6a96a47163 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java @@ -16,8 +16,9 @@ */ package handlers.dailymissionhandlers; -import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.Config; import org.l2jmobius.gameserver.enums.DailyMissionStatus; @@ -41,7 +42,7 @@ public class MonsterDailyMissionHandler extends AbstractDailyMissionHandler private final int _amount; private final int _minLevel; private final int _maxLevel; - private final List _ids = new ArrayList<>(); + private final Set _ids = new HashSet<>(); public MonsterDailyMissionHandler(DailyMissionDataHolder holder) { diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/itemhandlers/PetFood.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/itemhandlers/PetFood.java index 3c5572d4ec..8b908ea095 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/itemhandlers/PetFood.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/itemhandlers/PetFood.java @@ -17,6 +17,7 @@ package handlers.itemhandlers; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.PetDataTable; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -79,7 +80,7 @@ public class PetFood implements IItemHandler final Player player = activeChar.getActingPlayer(); if (player.isMounted()) { - final List foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); + final Set foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); if (foodIds.contains(item.getId()) && player.destroyItem("Consume", item.getObjectId(), 1, null, false)) { player.broadcastPacket(new MagicSkillUse(player, player, skillId, skillLevel, 0, 0)); diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java index 2ad282f683..99f45fbb41 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.ClanHallData; import org.l2jmobius.gameserver.model.StatSet; @@ -32,12 +33,12 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpCheckResidenceSkillCondition implements ISkillCondition { - private final List _residencesId; + private final Set _residencesId = new HashSet<>(); private final boolean _isWithin; public OpCheckResidenceSkillCondition(StatSet params) { - _residencesId = params.getList("residencesId", Integer.class); + _residencesId.addAll(params.getList("residencesId", Integer.class)); _isWithin = params.getBoolean("isWithin"); } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java index fc2934423b..4a8282d988 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java @@ -16,9 +16,9 @@ */ package handlers.skillconditionhandlers; -import java.util.ArrayList; -import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -28,18 +28,18 @@ import org.l2jmobius.gameserver.model.skill.ISkillCondition; import org.l2jmobius.gameserver.model.skill.Skill; /** - * @author UnAfraid + * @author UnAfraid, Mobius */ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition { - private final List _npcIds = new ArrayList<>(); + private final Set _npcIds = new HashSet<>(); public OpNeedSummonOrPetSkillCondition(StatSet params) { - final List npcIds = params.getList("npcIds", String.class); + final List npcIds = params.getList("npcIds", Integer.class); if (npcIds != null) { - npcIds.stream().map(Integer::valueOf).forEach(_npcIds::add); + _npcIds.addAll(npcIds); } } @@ -47,7 +47,19 @@ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition public boolean canUse(Creature caster, Skill skill, WorldObject target) { final Summon pet = caster.getPet(); - final Collection summons = caster.getServitors().values(); - return ((pet != null) && _npcIds.stream().anyMatch(npcId -> npcId == pet.getId())) || summons.stream().anyMatch(summon -> _npcIds.contains(summon.getId())); + if ((pet != null) && _npcIds.contains(pet.getId())) + { + return true; + } + + for (Summon summon : caster.getServitors().values()) + { + if (_npcIds.contains(summon.getId())) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java index 8541bc62b4..ef81b291d4 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,11 +30,11 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetDoorSkillCondition implements ISkillCondition { - private final List _doorIds; + private final Set _doorIds = new HashSet<>(); public OpTargetDoorSkillCondition(StatSet params) { - _doorIds = params.getList("doorIds", Integer.class); + _doorIds.addAll(params.getList("doorIds", Integer.class)); } @Override diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java index 3ce4145703..0ccd571e19 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,17 +30,17 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetNpcSkillCondition implements ISkillCondition { - private final List _npcId; + private final Set _npcIds = new HashSet<>(); public OpTargetNpcSkillCondition(StatSet params) { - _npcId = params.getList("npcIds", Integer.class); + _npcIds.addAll(params.getList("npcIds", Integer.class)); } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget(); - return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId()); + return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcIds.contains(actualTarget.getId()); } } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/instances/AbstractInstance.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/instances/AbstractInstance.java index d485c2c36d..4a0a3d35d4 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/instances/AbstractInstance.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/instances/AbstractInstance.java @@ -16,9 +16,10 @@ */ package instances; +import java.util.HashSet; import java.util.List; +import java.util.Set; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.enums.InstanceReenterType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.instancemanager.InstanceManager; @@ -40,25 +41,29 @@ import ai.AbstractNpcAI; */ public abstract class AbstractInstance extends AbstractNpcAI { - private final int[] _templateIds; + private final Set _templateIds = new HashSet<>(); - public AbstractInstance(int... templateId) + public AbstractInstance(int... templateIds) { - if (templateId.length == 0) + if (templateIds.length == 0) { throw new IllegalStateException("No template ids were provided!"); } - _templateIds = templateId; + + for (int templateId : templateIds) + { + _templateIds.add(templateId); + } } - public int[] getTemplateId() + public Set getTemplateId() { return _templateIds; } public boolean isInInstance(Instance instance) { - return (instance != null) && CommonUtil.contains(_templateIds, instance.getTemplateId()); + return (instance != null) && _templateIds.contains(instance.getTemplateId()); } /** diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/Config.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/Config.java index 787bb571f3..62aba2df97 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/Config.java @@ -287,7 +287,7 @@ public class Config public static boolean AUTO_LOOT_SLOT_LIMIT; public static int LOOT_RAIDS_PRIVILEGE_INTERVAL; public static int LOOT_RAIDS_PRIVILEGE_CC_SIZE; - public static List AUTO_LOOT_ITEM_IDS; + public static Set AUTO_LOOT_ITEM_IDS; public static boolean ENABLE_KEYBOARD_MOVEMENT; public static int UNSTUCK_INTERVAL; public static int TELEPORT_WATCHDOG_TIMEOUT; @@ -455,7 +455,7 @@ public class Config public static boolean ALLOW_DISCARDITEM; public static int AUTODESTROY_ITEM_AFTER; public static int HERB_AUTO_DESTROY_TIME; - public static List LIST_PROTECTED_ITEMS; + public static Set LIST_PROTECTED_ITEMS; public static boolean DATABASE_CLEAN_UP; public static int CHAR_DATA_STORE_INTERVAL; public static int CLAN_VARIABLES_STORE_INTERVAL; @@ -546,7 +546,7 @@ public class Config public static boolean ALT_OLY_LOG_FIGHTS; public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS; public static boolean ALT_OLY_ANNOUNCE_GAMES; - public static List LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(); + public static Set LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(); public static int ALT_OLY_WEAPON_ENCHANT_LIMIT; public static int ALT_OLY_ARMOR_ENCHANT_LIMIT; public static int ALT_OLY_WAIT_TIME; @@ -1251,9 +1251,9 @@ public class Config public static int AUTO_CP_PERCENTAGE; public static int AUTO_HP_PERCENTAGE; public static int AUTO_MP_PERCENTAGE; - public static List AUTO_CP_ITEM_IDS; - public static List AUTO_HP_ITEM_IDS; - public static List AUTO_MP_ITEM_IDS; + public static Set AUTO_CP_ITEM_IDS; + public static Set AUTO_HP_ITEM_IDS; + public static Set AUTO_MP_ITEM_IDS; public static boolean CUSTOM_STARTING_LOC; public static int CUSTOM_STARTING_LOC_X; public static int CUSTOM_STARTING_LOC_Y; @@ -1263,7 +1263,7 @@ public class Config public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; public static int MOB_MIN_SPAWN_RANGE; public static int MOB_MAX_SPAWN_RANGE; - public static List MOBS_LIST_NOT_RANDOM; + public static Set MOBS_LIST_NOT_RANDOM; public static boolean FREE_JUMPS_FOR_ALL; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; @@ -1282,7 +1282,7 @@ public class Config public static boolean COMMUNITY_PREMIUM_SYSTEM_ENABLED; public static int COMMUNITY_PREMIUM_COIN_ID; public static int COMMUNITY_PREMIUM_PRICE_PER_DAY; - public static List COMMUNITY_AVAILABLE_BUFFS; + public static Set COMMUNITY_AVAILABLE_BUFFS; public static Map COMMUNITY_AVAILABLE_TELEPORTS; public static boolean CUSTOM_DEPOSITABLE_ENABLED; public static boolean CUSTOM_DEPOSITABLE_QUEST_ITEMS; @@ -1947,7 +1947,7 @@ public class Config LOOT_RAIDS_PRIVILEGE_INTERVAL = characterConfig.getInt("RaidLootRightsInterval", 900) * 1000; LOOT_RAIDS_PRIVILEGE_CC_SIZE = characterConfig.getInt("RaidLootRightsCCSize", 45); final String[] autoLootItemIds = characterConfig.getString("AutoLootItemIds", "0").split(","); - AUTO_LOOT_ITEM_IDS = new ArrayList<>(autoLootItemIds.length); + AUTO_LOOT_ITEM_IDS = new HashSet<>(autoLootItemIds.length); for (String item : autoLootItemIds) { Integer itm = 0; @@ -2101,7 +2101,7 @@ public class Config AUTODESTROY_ITEM_AFTER = generalConfig.getInt("AutoDestroyDroppedItemAfter", 600); HERB_AUTO_DESTROY_TIME = generalConfig.getInt("AutoDestroyHerbTime", 60) * 1000; final String[] split = generalConfig.getString("ListOfProtectedItems", "0").split(","); - LIST_PROTECTED_ITEMS = new ArrayList<>(split.length); + LIST_PROTECTED_ITEMS = new HashSet<>(split.length); for (String id : split) { LIST_PROTECTED_ITEMS.add(Integer.parseInt(id)); @@ -2502,7 +2502,7 @@ public class Config if (!olyRestrictedItems.isEmpty()) { final String[] olyRestrictedItemsSplit = olyRestrictedItems.split(","); - LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(olyRestrictedItemsSplit.length); + LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(olyRestrictedItemsSplit.length); for (String id : olyRestrictedItemsSplit) { LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id)); @@ -2663,17 +2663,17 @@ public class Config AUTO_CP_PERCENTAGE = autoPotionsConfig.getInt("AutoCpPercentage", 70); AUTO_HP_PERCENTAGE = autoPotionsConfig.getInt("AutoHpPercentage", 70); AUTO_MP_PERCENTAGE = autoPotionsConfig.getInt("AutoMpPercentage", 70); - AUTO_CP_ITEM_IDS = new ArrayList<>(); + AUTO_CP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoCpItemIds", "0").split(",")) { AUTO_CP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_HP_ITEM_IDS = new ArrayList<>(); + AUTO_HP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoHpItemIds", "0").split(",")) { AUTO_HP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_MP_ITEM_IDS = new ArrayList<>(); + AUTO_MP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoMpItemIds", "0").split(",")) { AUTO_MP_ITEM_IDS.add(Integer.parseInt(s)); @@ -3284,7 +3284,7 @@ public class Config COMMUNITY_PREMIUM_COIN_ID = communityBoardConfig.getInt("CommunityPremiumBuyCoinId", 57); COMMUNITY_PREMIUM_PRICE_PER_DAY = communityBoardConfig.getInt("CommunityPremiumPricePerDay", 1000000); final String[] allowedBuffs = communityBoardConfig.getString("CommunityAvailableBuffs", "").split(","); - COMMUNITY_AVAILABLE_BUFFS = new ArrayList<>(allowedBuffs.length); + COMMUNITY_AVAILABLE_BUFFS = new HashSet<>(allowedBuffs.length); for (String s : allowedBuffs) { COMMUNITY_AVAILABLE_BUFFS.add(Integer.parseInt(s)); @@ -3559,7 +3559,7 @@ public class Config if (ENABLE_RANDOM_MONSTER_SPAWNS) { final String[] mobsIds = randomSpawnsConfig.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); - MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + MOBS_LIST_NOT_RANDOM = new HashSet<>(mobsIds.length); for (String id : mobsIds) { MOBS_LIST_NOT_RANDOM.add(Integer.parseInt(id)); diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java index d6e0183c6f..c3977185b4 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java @@ -202,8 +202,7 @@ public class ClanHallData implements IXmlReader final Door door = DoorData.getInstance().getDoor(doorId); for (ClanHall ch : _clanHalls.values()) { - final List doors = ch.getDoors(); - if ((doors != null) && doors.contains(door)) + if (ch.getDoors().contains(door)) { return ch; } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java index 6aa0a1fdde..fb395b9e2d 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java @@ -17,10 +17,10 @@ package org.l2jmobius.gameserver.data.xml; import java.io.File; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -42,7 +42,7 @@ public class FakePlayerData implements IXmlReader private final Map _fakePlayerInfos = new HashMap<>(); private final Map _fakePlayerNames = new HashMap<>(); private final Map _fakePlayerIds = new HashMap<>(); - private final List _talkableFakePlayerNames = new ArrayList<>(); + private final Set _talkableFakePlayerNames = new HashSet<>(); protected FakePlayerData() { diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/data/xml/VariationData.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/data/xml/VariationData.java index c29a10baa2..079f5b3077 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/data/xml/VariationData.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/data/xml/VariationData.java @@ -20,8 +20,10 @@ import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Logger; @@ -114,14 +116,11 @@ public class VariationData implements IXmlReader }); // Support for specific item ids. - final List itemIds = new ArrayList<>(); + final Set itemIds = new HashSet<>(); forEach(categoryNode, "item", optionNode -> { final int itemId = parseInteger(optionNode.getAttributes(), "id"); - if (!itemIds.contains(itemId)) - { - itemIds.add(itemId); - } + itemIds.add(itemId); }); forEach(categoryNode, "items", optionNode -> { @@ -129,10 +128,7 @@ public class VariationData implements IXmlReader final int toId = parseInteger(optionNode.getAttributes(), "to"); for (int id = fromId; id <= toId; id++) { - if (!itemIds.contains(id)) - { - itemIds.add(id); - } + itemIds.add(id); } }); diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java index d335b95954..1122d7b9ba 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java @@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -49,7 +51,7 @@ import org.l2jmobius.gameserver.util.Util; public class SellBuffsManager implements IXmlReader { private static final Logger LOGGER = Logger.getLogger(SellBuffsManager.class.getName()); - private static final List ALLOWED_BUFFS = new ArrayList<>(); + private static final Set ALLOWED_BUFFS = new HashSet<>(); private static final String HTML_FOLDER = "data/html/mods/SellBuffs/"; protected SellBuffsManager() @@ -76,11 +78,7 @@ public class SellBuffsManager implements IXmlReader { final Element elem = (Element) node.item(i); final int skillId = Integer.parseInt(elem.getAttribute("id")); - - if (!ALLOWED_BUFFS.contains(skillId)) - { - ALLOWED_BUFFS.add(skillId); - } + ALLOWED_BUFFS.add(skillId); } } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java index b10f75ef3d..1e45a21319 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java @@ -19,8 +19,10 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; @@ -67,7 +69,7 @@ public class WalkingManager implements IXmlReader public static final byte REPEAT_TELE_FIRST = 2; public static final byte REPEAT_RANDOM = 3; - private final List _targetedNpcIds = new ArrayList<>(); + private final Set _targetedNpcIds = new HashSet<>(); private final Map _routes = new HashMap<>(); // all available routes private final Map _activeRoutes = new HashMap<>(); // each record represents NPC, moving by predefined route from _routes, and moving progress private final Map _routesToAttach = new HashMap<>(); // each record represents NPC and all available routes for it diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/BlockList.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/BlockList.java index d9ef2e01fb..984f05b22d 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/BlockList.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/BlockList.java @@ -19,9 +19,9 @@ package org.l2jmobius.gameserver.model; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -36,10 +36,11 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; public class BlockList { private static final Logger LOGGER = Logger.getLogger(BlockList.class.getName()); - private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); + + private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); private final Player _owner; - private List _blockList; + private Set _blockList; public BlockList(Player owner) { @@ -68,9 +69,9 @@ public class BlockList OFFLINE_LIST.put(_owner.getObjectId(), _blockList); } - private static List loadList(int objId) + private static Set loadList(int objId) { - final List list = new ArrayList<>(); + final Set list = new HashSet<>(); try (Connection con = DatabaseFactory.getConnection(); PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1")) { @@ -158,7 +159,7 @@ public class BlockList _owner.setMessageRefusal(value); } - private List getBlockList() + private Set getBlockList() { return _blockList; } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/PetData.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/PetData.java index b534c21f36..231b85e85f 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/PetData.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/PetData.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; import org.l2jmobius.gameserver.model.holders.SkillHolder; @@ -40,7 +42,7 @@ public class PetData private int _minLevel = Byte.MAX_VALUE; private int _maxLevel = 0; private boolean _syncLevel = false; - private final List _food = new ArrayList<>(); + private final Set _food = new HashSet<>(); public PetData(int npcId, int itemId) { @@ -133,7 +135,7 @@ public class PetData /** * @return the pet's food list. */ - public List getFood() + public Set getFood() { return _food; } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/SkillLearn.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/SkillLearn.java index a69d30f105..3d5704b5f2 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/SkillLearn.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/SkillLearn.java @@ -16,9 +16,8 @@ */ package org.l2jmobius.gameserver.model; -import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashSet; -import java.util.List; import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -40,12 +39,12 @@ public class SkillLearn private final int _getDualClassLevel; private final boolean _autoGet; private final long _levelUpSp; - private final List _requiredItems = new ArrayList<>(); - private final List _races = new ArrayList<>(); - private final List _preReqSkills = new ArrayList<>(); + private final Set _requiredItems = new HashSet<>(1); + private final Set _races = EnumSet.noneOf(Race.class); + private final Set _preReqSkills = new HashSet<>(1); private SocialClass _socialClass; private final boolean _residenceSkill; - private final List _residenceIds = new ArrayList<>(); + private final Set _residenceIds = new HashSet<>(1); private final boolean _learnedByNpc; private final boolean _learnedByFS; private final Set _removeSkills = new HashSet<>(1); @@ -133,9 +132,9 @@ public class SkillLearn } /** - * @return the list with the item holders required to acquire this skill. + * @return the set with the item holders required to acquire this skill. */ - public List getRequiredItems() + public Set getRequiredItems() { return _requiredItems; } @@ -150,9 +149,9 @@ public class SkillLearn } /** - * @return a list with the races that can acquire this skill. + * @return a set with the races that can acquire this skill. */ - public List getRaces() + public Set getRaces() { return _races; } @@ -167,9 +166,9 @@ public class SkillLearn } /** - * @return the list of skill holders required to acquire this skill. + * @return the set of skill holders required to acquire this skill. */ - public List getPreReqSkills() + public Set getPreReqSkills() { return _preReqSkills; } @@ -212,9 +211,9 @@ public class SkillLearn } /** - * @return a list with the Ids where this skill is available. + * @return a set with the Ids where this skill is available. */ - public List getResidenceIds() + public Set getResidenceIds() { return _residenceIds; } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java index 1dc8499399..f0c453e361 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java @@ -22,7 +22,6 @@ import java.sql.ResultSet; import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.List; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; @@ -153,7 +152,7 @@ public class Pet extends Summon broadcastStatusUpdate(); - final List foodIds = getPetData().getFood(); + final Set foodIds = getPetData().getFood(); if (foodIds.isEmpty()) { if (isUncontrollable()) diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java index 11efe435d8..1ed0ee81a4 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java @@ -16,8 +16,8 @@ */ package org.l2jmobius.gameserver.model.actor.instance; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import org.l2jmobius.commons.threads.ThreadPool; @@ -57,7 +57,7 @@ public class Trap extends Npc private boolean _isTriggered; private final int _lifeTime; private Player _owner; - private final List _playersWhoDetectedMe = new ArrayList<>(); + private final Set _playersWhoDetectedMe = new HashSet<>(); private final SkillHolder _skill; private int _remainingTime; // Tasks diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java index 71ef076212..3ba8c20a9b 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor.tasks.player; -import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -69,11 +69,12 @@ public class PetFeedTask implements Runnable _player.sendPacket(SystemMessageId.YOU_ARE_OUT_OF_FEED_MOUNT_STATUS_CANCELED); } - final List foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); + final Set foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); if (foodIds.isEmpty()) { return; } + Item food = null; for (int id : foodIds) { diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java index 50d2a821c3..2611b5f121 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.actor.Creature; @@ -29,9 +29,9 @@ import org.l2jmobius.gameserver.model.zone.ZoneType; */ public class ConditionPlayerInsideZoneId extends Condition { - private final List _zones; + private final Set _zones; - public ConditionPlayerInsideZoneId(List zones) + public ConditionPlayerInsideZoneId(Set zones) { _zones = zones; } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java index c15065eca2..d644f663f5 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Player; @@ -29,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerInstanceId extends Condition { - private final List _instanceIds; + private final Set _instanceIds; /** * Instantiates a new condition player instance id. * @param instanceIds the instance ids */ - public ConditionPlayerInstanceId(List instanceIds) + public ConditionPlayerInstanceId(Set instanceIds) { _instanceIds = instanceIds; } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java index 14d61089ed..7c375ec45e 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -28,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerRace extends Condition { - private final Race[] _races; + private final Set _races; /** * Instantiates a new condition player race. * @param races the list containing the allowed races. */ - public ConditionPlayerRace(Race[] races) + public ConditionPlayerRace(Set races) { _races = races; } @@ -46,6 +47,6 @@ public class ConditionPlayerRace extends Condition { return false; } - return CommonUtil.contains(_races, effector.getActingPlayer().getRace()); + return _races.contains(effector.getActingPlayer().getRace()); } } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java index 0f54766571..0b326e3f40 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId())) + if (_npcIds.contains(target.getId())) { existNpc = true; break; diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java index c5c9b5ff0e..db64b6bd7b 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromSummonedNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromSummonedNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromSummonedNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromSummonedNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId()) && (effector == target.getSummoner())) + if (_npcIds.contains(target.getId()) && (effector == target.getSummoner())) { existNpc = true; break; diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java index a3fb0f5374..a47b4b4983 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetClassIdRestriction extends Condition { - private final List _classIds; + private final Set _classIds; /** * Instantiates a new condition target class id restriction. * @param classId the class id */ - public ConditionTargetClassIdRestriction(List classId) + public ConditionTargetClassIdRestriction(Set classId) { _classIds = classId; } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java index 82b1bd5877..9bb694f4ef 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetNpcId extends Condition { - private final List _npcIds; + private final Set _npcIds; /** * Instantiates a new condition target npc id. * @param npcIds the npc ids */ - public ConditionTargetNpcId(List npcIds) + public ConditionTargetNpcId(Set npcIds) { _npcIds = npcIds; } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java index f26329bc21..5c86f26ae5 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.holders; -import java.util.Collection; +import java.util.Set; /** * @author Mobius @@ -25,9 +25,9 @@ public class EventDropHolder extends DropHolder { private final int _minLevel; private final int _maxLevel; - private final Collection _monsterIds; + private final Set _monsterIds; - public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Collection monsterIds) + public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Set monsterIds) { super(null, itemId, min, max, chance); _minLevel = minLevel; @@ -45,7 +45,7 @@ public class EventDropHolder extends DropHolder return _maxLevel; } - public Collection getMonsterIds() + public Set getMonsterIds() { return _monsterIds; } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/item/Henna.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/item/Henna.java index af805ac1bc..6c2c9feea3 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/item/Henna.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/item/Henna.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model.item; import java.util.ArrayList; import java.util.EnumMap; +import java.util.EnumSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.enums.ClassId; import org.l2jmobius.gameserver.model.StatSet; @@ -42,7 +44,7 @@ public class Henna private final int _cancelCount; private final int _duration; private final List _skills; - private final List _wearClass; + private final Set _wearClass; public Henna(StatSet set) { @@ -63,7 +65,7 @@ public class Henna _cancelCount = set.getInt("cancel_count"); _duration = set.getInt("duration", -1); _skills = new ArrayList<>(); - _wearClass = new ArrayList<>(); + _wearClass = EnumSet.noneOf(ClassId.class); } /** @@ -159,7 +161,7 @@ public class Henna /** * @return the list with the allowed classes to wear this dye. */ - public List getAllowedWearClass() + public Set getAllowedWearClass() { return _wearClass; } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java index d74b1218d3..5d694e5169 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java @@ -17,9 +17,10 @@ package org.l2jmobius.gameserver.model.item.appearance; import java.time.Duration; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.enums.Race; @@ -47,12 +48,12 @@ public class AppearanceStone private final ArmorType _armorType; private final AppearanceHandType _handType; private final AppearanceMagicType _magicType; - private List _crystalTypes; - private List _targetTypes; - private List _bodyParts; - private List _races; - private List _racesNot; - private List _allVisualIds; + private Set _crystalTypes; + private Set _targetTypes; + private Set _bodyParts; + private Set _races; + private Set _racesNot; + private Set _allVisualIds; public AppearanceStone(StatSet set) { @@ -172,35 +173,35 @@ public class AppearanceStone { if (_crystalTypes == null) { - _crystalTypes = new ArrayList<>(); + _crystalTypes = EnumSet.noneOf(CrystalType.class); } _crystalTypes.add(type); } - public List getCrystalTypes() + public Set getCrystalTypes() { - return _crystalTypes != null ? _crystalTypes : Collections.emptyList(); + return _crystalTypes != null ? _crystalTypes : Collections.emptySet(); } public void addTargetType(AppearanceTargetType type) { if (_targetTypes == null) { - _targetTypes = new ArrayList<>(); + _targetTypes = EnumSet.noneOf(AppearanceTargetType.class); } _targetTypes.add(type); } - public List getTargetTypes() + public Set getTargetTypes() { - return _targetTypes != null ? _targetTypes : Collections.emptyList(); + return _targetTypes != null ? _targetTypes : Collections.emptySet(); } public void addBodyPart(long part) { if (_bodyParts == null) { - _bodyParts = new ArrayList<>(); + _bodyParts = new HashSet<>(); } _bodyParts.add(part); } @@ -209,47 +210,47 @@ public class AppearanceStone { if (_allVisualIds == null) { - _allVisualIds = new ArrayList<>(); + _allVisualIds = new HashSet<>(); } _allVisualIds.add(appearanceHolder); } - public List getVisualIds() + public Set getVisualIds() { - return _allVisualIds != null ? _allVisualIds : Collections.emptyList(); + return _allVisualIds != null ? _allVisualIds : Collections.emptySet(); } - public List getBodyParts() + public Set getBodyParts() { - return _bodyParts != null ? _bodyParts : Collections.emptyList(); + return _bodyParts != null ? _bodyParts : Collections.emptySet(); } public void addRace(Race race) { if (_races == null) { - _races = new ArrayList<>(); + _races = EnumSet.noneOf(Race.class); } _races.add(race); } - public List getRaces() + public Set getRaces() { - return _races != null ? _races : Collections.emptyList(); + return _races != null ? _races : Collections.emptySet(); } public void addRaceNot(Race race) { if (_racesNot == null) { - _racesNot = new ArrayList<>(); + _racesNot = EnumSet.noneOf(Race.class); } _racesNot.add(race); } - public List getRacesNot() + public Set getRacesNot() { - return _racesNot != null ? _racesNot : Collections.emptyList(); + return _racesNot != null ? _racesNot : Collections.emptySet(); } /** @@ -302,7 +303,7 @@ public class AppearanceStone { // Seems like in retail item with already changed appearance, can be changed again without being restored. - final AppearanceTargetType targetType = getTargetTypes().get(0); + final AppearanceTargetType targetType = getTargetTypes().stream().findFirst().get(); switch (targetType) { case NONE: diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java index c21f776020..9af155da21 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java @@ -16,16 +16,16 @@ */ package org.l2jmobius.gameserver.model.item.enchant; +import java.util.EnumSet; +import java.util.Set; import java.util.logging.Logger; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.item.ItemTemplate; import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.model.item.type.CrystalType; import org.l2jmobius.gameserver.model.item.type.EtcItemType; -import org.l2jmobius.gameserver.model.item.type.ItemType; /** * @author UnAfraid @@ -34,28 +34,29 @@ public abstract class AbstractEnchantItem { protected static final Logger LOGGER = Logger.getLogger(AbstractEnchantItem.class.getName()); - private static final ItemType[] ENCHANT_TYPES = new ItemType[] + private static final Set ENCHANT_TYPES = EnumSet.noneOf(EtcItemType.class); + static { - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM, - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP, - EtcItemType.BLESS_ENCHT_AM, - EtcItemType.BLESS_ENCHT_AM_DOWN, - EtcItemType.BLESS_ENCHT_WP, - EtcItemType.ENCHT_AM, - EtcItemType.ENCHT_WP, - EtcItemType.ENCHT_WP_DOWN, - EtcItemType.ENCHT_AM_DOWN, - EtcItemType.GIANT_ENCHT_AM, - EtcItemType.GIANT_ENCHT_WP, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - }; + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP_DOWN); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + } private final int _id; private final CrystalType _grade; @@ -73,7 +74,7 @@ public abstract class AbstractEnchantItem { throw new NullPointerException(); } - else if (!CommonUtil.contains(ENCHANT_TYPES, getItem().getItemType())) + else if (!ENCHANT_TYPES.contains(getItem().getItemType())) { throw new IllegalAccessError(); } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/options/OptionDataCategory.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/options/OptionDataCategory.java index dd8d1e4281..4e7856e4a2 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/options/OptionDataCategory.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/options/OptionDataCategory.java @@ -16,9 +16,9 @@ */ package org.l2jmobius.gameserver.model.options; -import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import org.l2jmobius.commons.util.Rnd; @@ -28,10 +28,10 @@ import org.l2jmobius.commons.util.Rnd; public class OptionDataCategory { private final Map _options; - private final List _itemIds; + private final Set _itemIds; private final double _chance; - public OptionDataCategory(Map options, List itemIds, double chance) + public OptionDataCategory(Map options, Set itemIds, double chance) { _options = options; _itemIds = itemIds; @@ -59,7 +59,7 @@ public class OptionDataCategory return result; } - public List getItemIds() + public Set getItemIds() { return _itemIds; } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java index 5ba6755084..18508d0145 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java @@ -24,8 +24,10 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Set; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -184,7 +186,7 @@ public class LongTimeEvent extends Quest final Node maxLevelNode = d.getAttributes().getNamedItem("maxLevel"); final int maxLevel = maxLevelNode == null ? Integer.MAX_VALUE : Integer.parseInt(maxLevelNode.getNodeValue()); final Node monsterIdsNode = d.getAttributes().getNamedItem("monsterIds"); - final List monsterIds = new ArrayList<>(); + final Set monsterIds = new HashSet<>(); if (monsterIdsNode != null) { for (String id : monsterIdsNode.getNodeValue().split(",")) diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/residences/ClanHall.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/residences/ClanHall.java index 0c0a529077..fcc850371b 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/residences/ClanHall.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/residences/ClanHall.java @@ -23,7 +23,9 @@ import java.sql.SQLException; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -61,9 +63,9 @@ public class ClanHall extends AbstractResidence private final int _minBid; final int _lease; private final int _deposit; - private final List _npcs; - private final List _doors; - private final List _teleports; + private final Set _npcs = new HashSet<>(); + private final Set _doors = new HashSet<>(); + private final Set _teleports = new HashSet<>(); private final Location _ownerLocation; private final Location _banishLocation; // Dynamic parameters @@ -85,9 +87,21 @@ public class ClanHall extends AbstractResidence _minBid = params.getInt("minBid"); _lease = params.getInt("lease"); _deposit = params.getInt("deposit"); - _npcs = params.getList("npcList", Integer.class); - _doors = params.getList("doorList", Door.class); - _teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + final List npcs = params.getList("npcList", Integer.class); + if (npcs != null) + { + _npcs.addAll(npcs); + } + final List doors = params.getList("doorList", Door.class); + if (doors != null) + { + _doors.addAll(doors); + } + final List teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + if (teleports != null) + { + _teleports.addAll(teleports); + } _ownerLocation = params.getLocation("owner_loc"); _banishLocation = params.getLocation("banish_loc"); // Set dynamic parameters (from DB) @@ -196,7 +210,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Door} related to this {@link ClanHall}. * @return all {@link Door} related to this {@link ClanHall} */ - public List getDoors() + public Set getDoors() { return _doors; } @@ -205,7 +219,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Npc} related to this {@link ClanHall}. * @return all {@link Npc} related to this {@link ClanHall} */ - public List getNpcs() + public Set getNpcs() { return _npcs; } @@ -324,7 +338,7 @@ public class ClanHall extends AbstractResidence return _banishLocation; } - public List getTeleportList() + public Set getTeleportList() { return _teleports; } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/siege/Castle.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/siege/Castle.java index 063570e334..27c7525c68 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/siege/Castle.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/siege/Castle.java @@ -21,8 +21,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.Calendar; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -82,7 +84,7 @@ public class Castle extends AbstractResidence private SiegeZone _zone = null; private ResidenceTeleportZone _teleZone; private Clan _formerOwner = null; - private final List _artefacts = new ArrayList<>(1); + private final Set _artefacts = new HashSet<>(1); private final Map _function = new ConcurrentHashMap<>(); private int _ticketBuyCount = 0; private boolean _isFirstMidVictory = false; @@ -1071,7 +1073,7 @@ public class Castle extends AbstractResidence _artefacts.add(artefact); } - public List getArtefacts() + public Set getArtefacts() { return _artefacts; } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java index 0c79677eae..4ebf954ee5 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.network.serverpackets; -import java.util.List; +import java.util.Set; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.gameserver.data.sql.CharNameTable; @@ -27,19 +27,19 @@ import org.l2jmobius.gameserver.network.OutgoingPackets; */ public class BlockListPacket implements IClientOutgoingPacket { - private final List _playersId; + private final Set _playerIds; - public BlockListPacket(List playersId) + public BlockListPacket(Set playerIds) { - _playersId = playersId; + _playerIds = playerIds; } @Override public boolean write(PacketWriter packet) { OutgoingPackets.BLOCK_LIST.writeId(packet); - packet.writeD(_playersId.size()); - for (int playerId : _playersId) + packet.writeD(_playerIds.size()); + for (int playerId : _playerIds) { packet.writeS(CharNameTable.getInstance().getNameById(playerId)); packet.writeS(""); // memo ? diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java index 8555bb6e86..eb5bfd05d8 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.network.serverpackets; import java.util.List; import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; import org.l2jmobius.commons.network.PacketWriter; @@ -37,7 +38,7 @@ public class ExAcquireSkillInfo implements IClientOutgoingPacket private final int _dualClassLevel; private final long _spCost; private final int _minLevel; - private final List _itemReq; + private final Set _itemReq; private final List _skillRem; /** diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java index 84b5fead76..a163a85735 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java @@ -35,7 +35,7 @@ public class ExChooseShapeShiftingItem implements IClientOutgoingPacket public ExChooseShapeShiftingItem(AppearanceStone stone) { _type = stone.getType(); - _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().get(0); + _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().stream().findFirst().get(); _itemId = stone.getId(); } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/util/DocumentBase.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/util/DocumentBase.java index ee1955dcf6..cd6eeb37fb 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/util/DocumentBase.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/util/DocumentBase.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.util; import java.io.File; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -392,12 +393,12 @@ public abstract class DocumentBase case "races": { final String[] racesVal = a.getNodeValue().split(","); - final Race[] races = new Race[racesVal.length]; + final Set races = EnumSet.noneOf(Race.class); for (int r = 0; r < racesVal.length; r++) { if (racesVal[r] != null) { - races[r] = Race.valueOf(racesVal[r]); + races.add(Race.valueOf(racesVal[r])); } } cond = joinAnd(cond, new ConditionPlayerRace(races)); @@ -673,13 +674,13 @@ public abstract class DocumentBase case "instanceid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final ArrayList array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInstanceId(array)); + cond = joinAnd(cond, new ConditionPlayerInstanceId(set)); break; } case "agathionid": @@ -730,10 +731,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -747,10 +748,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -836,13 +837,13 @@ public abstract class DocumentBase case "insidezoneid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInsideZoneId(array)); + cond = joinAnd(cond, new ConditionPlayerInsideZoneId(set)); break; } case "checkabnormal": @@ -975,13 +976,13 @@ public abstract class DocumentBase case "class_id_restriction": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetClassIdRestriction(array)); + cond = joinAnd(cond, new ConditionTargetClassIdRestriction(set)); break; } case "active_effect_id": @@ -1059,13 +1060,13 @@ public abstract class DocumentBase case "npcid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetNpcId(array)); + cond = joinAnd(cond, new ConditionTargetNpcId(set)); break; } case "npctype": diff --git a/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/handlers/bypasshandlers/Link.java b/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/handlers/bypasshandlers/Link.java index 1fa74edabd..06390c5abd 100644 --- a/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/handlers/bypasshandlers/Link.java +++ b/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/handlers/bypasshandlers/Link.java @@ -16,7 +16,9 @@ */ package handlers.bypasshandlers; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.HashSet; +import java.util.Set; + import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.handler.IBypassHandler; import org.l2jmobius.gameserver.model.actor.Creature; @@ -31,52 +33,53 @@ public class Link implements IBypassHandler "Link" }; - private static final String[] VALID_LINKS = + private static final Set VALID_LINKS = new HashSet<>(); + static { - "common/imbue_soul_crystal.htm", - "common/extract_soul_crystal.htm", - "common/attribute_info.htm", - "common/augmentation_01.htm", - "common/augmentation_02.htm", - "common/augmentation_exchange.htm", - "common/crafting_01.htm", - "common/crafting_02.htm", - "common/crafting_03.htm", - "common/cursed_to_unidentified.htm", - "common/duals_01.htm", - "common/duals_02.htm", - "common/duals_03.htm", - "common/g_cube_warehouse001.htm", - "common/skill_enchant_help.htm", - "common/skill_enchant_help_01.htm", - "common/skill_enchant_help_02.htm", - "common/skill_enchant_help_03.htm", - "common/smelting_trade001.htm", - "common/weapon_sa_01.htm", - "common/welcomeback002.htm", - "common/welcomeback003.htm", - "default/BlessingOfProtection.htm", - "default/SupportMagic.htm", - "default/SupportMagicServitor.htm", - "fisherman/exchange_old_items.htm", - "fisherman/fish_appearance_exchange.htm", - "fisherman/fishing_manual001.htm", - "fisherman/fishing_manual002.htm", - "fisherman/fishing_manual003.htm", - "fisherman/fishing_manual004.htm", - "fisherman/fishing_manual008.htm", - "fisherman/fishing_manual009.htm", - "fisherman/fishing_manual010.htm", - "fortress/foreman.htm", - "guard/kamaloka_help.htm", - "guard/kamaloka_level.htm", - "petmanager/evolve.htm", - "petmanager/exchange.htm", - "petmanager/instructions.htm", - "teleporter/separatedsoul.htm", - "warehouse/clanwh.htm", - "warehouse/privatewh.htm", - }; + VALID_LINKS.add("common/imbue_soul_crystal.htm"); + VALID_LINKS.add("common/extract_soul_crystal.htm"); + VALID_LINKS.add("common/attribute_info.htm"); + VALID_LINKS.add("common/augmentation_01.htm"); + VALID_LINKS.add("common/augmentation_02.htm"); + VALID_LINKS.add("common/augmentation_exchange.htm"); + VALID_LINKS.add("common/crafting_01.htm"); + VALID_LINKS.add("common/crafting_02.htm"); + VALID_LINKS.add("common/crafting_03.htm"); + VALID_LINKS.add("common/cursed_to_unidentified.htm"); + VALID_LINKS.add("common/duals_01.htm"); + VALID_LINKS.add("common/duals_02.htm"); + VALID_LINKS.add("common/duals_03.htm"); + VALID_LINKS.add("common/g_cube_warehouse001.htm"); + VALID_LINKS.add("common/skill_enchant_help.htm"); + VALID_LINKS.add("common/skill_enchant_help_01.htm"); + VALID_LINKS.add("common/skill_enchant_help_02.htm"); + VALID_LINKS.add("common/skill_enchant_help_03.htm"); + VALID_LINKS.add("common/smelting_trade001.htm"); + VALID_LINKS.add("common/weapon_sa_01.htm"); + VALID_LINKS.add("common/welcomeback002.htm"); + VALID_LINKS.add("common/welcomeback003.htm"); + VALID_LINKS.add("default/BlessingOfProtection.htm"); + VALID_LINKS.add("default/SupportMagic.htm"); + VALID_LINKS.add("default/SupportMagicServitor.htm"); + VALID_LINKS.add("fisherman/exchange_old_items.htm"); + VALID_LINKS.add("fisherman/fish_appearance_exchange.htm"); + VALID_LINKS.add("fisherman/fishing_manual001.htm"); + VALID_LINKS.add("fisherman/fishing_manual002.htm"); + VALID_LINKS.add("fisherman/fishing_manual003.htm"); + VALID_LINKS.add("fisherman/fishing_manual004.htm"); + VALID_LINKS.add("fisherman/fishing_manual008.htm"); + VALID_LINKS.add("fisherman/fishing_manual009.htm"); + VALID_LINKS.add("fisherman/fishing_manual010.htm"); + VALID_LINKS.add("fortress/foreman.htm"); + VALID_LINKS.add("guard/kamaloka_help.htm"); + VALID_LINKS.add("guard/kamaloka_level.htm"); + VALID_LINKS.add("petmanager/evolve.htm"); + VALID_LINKS.add("petmanager/exchange.htm"); + VALID_LINKS.add("petmanager/instructions.htm"); + VALID_LINKS.add("teleporter/separatedsoul.htm"); + VALID_LINKS.add("warehouse/clanwh.htm"); + VALID_LINKS.add("warehouse/privatewh.htm"); + } @Override public boolean useBypass(String command, Player player, Creature target) @@ -94,12 +97,13 @@ public class Link implements IBypassHandler return false; } - String content = CommonUtil.contains(VALID_LINKS, htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; + String content = VALID_LINKS.contains(htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; // Precaution. if (htmlPath.startsWith("teleporter/") && !(player.getTarget() instanceof Teleporter)) { content = null; } + final NpcHtmlMessage html = new NpcHtmlMessage(target != null ? target.getObjectId() : 0); if (content != null) { diff --git a/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java b/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java index ae22dcd5f9..6a96a47163 100644 --- a/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java +++ b/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java @@ -16,8 +16,9 @@ */ package handlers.dailymissionhandlers; -import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.Config; import org.l2jmobius.gameserver.enums.DailyMissionStatus; @@ -41,7 +42,7 @@ public class MonsterDailyMissionHandler extends AbstractDailyMissionHandler private final int _amount; private final int _minLevel; private final int _maxLevel; - private final List _ids = new ArrayList<>(); + private final Set _ids = new HashSet<>(); public MonsterDailyMissionHandler(DailyMissionDataHolder holder) { diff --git a/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/handlers/itemhandlers/PetFood.java b/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/handlers/itemhandlers/PetFood.java index 3c5572d4ec..8b908ea095 100644 --- a/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/handlers/itemhandlers/PetFood.java +++ b/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/handlers/itemhandlers/PetFood.java @@ -17,6 +17,7 @@ package handlers.itemhandlers; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.PetDataTable; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -79,7 +80,7 @@ public class PetFood implements IItemHandler final Player player = activeChar.getActingPlayer(); if (player.isMounted()) { - final List foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); + final Set foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); if (foodIds.contains(item.getId()) && player.destroyItem("Consume", item.getObjectId(), 1, null, false)) { player.broadcastPacket(new MagicSkillUse(player, player, skillId, skillLevel, 0, 0)); diff --git a/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java b/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java index 2ad282f683..99f45fbb41 100644 --- a/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java +++ b/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.ClanHallData; import org.l2jmobius.gameserver.model.StatSet; @@ -32,12 +33,12 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpCheckResidenceSkillCondition implements ISkillCondition { - private final List _residencesId; + private final Set _residencesId = new HashSet<>(); private final boolean _isWithin; public OpCheckResidenceSkillCondition(StatSet params) { - _residencesId = params.getList("residencesId", Integer.class); + _residencesId.addAll(params.getList("residencesId", Integer.class)); _isWithin = params.getBoolean("isWithin"); } diff --git a/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java b/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java index fc2934423b..4a8282d988 100644 --- a/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java +++ b/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java @@ -16,9 +16,9 @@ */ package handlers.skillconditionhandlers; -import java.util.ArrayList; -import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -28,18 +28,18 @@ import org.l2jmobius.gameserver.model.skill.ISkillCondition; import org.l2jmobius.gameserver.model.skill.Skill; /** - * @author UnAfraid + * @author UnAfraid, Mobius */ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition { - private final List _npcIds = new ArrayList<>(); + private final Set _npcIds = new HashSet<>(); public OpNeedSummonOrPetSkillCondition(StatSet params) { - final List npcIds = params.getList("npcIds", String.class); + final List npcIds = params.getList("npcIds", Integer.class); if (npcIds != null) { - npcIds.stream().map(Integer::valueOf).forEach(_npcIds::add); + _npcIds.addAll(npcIds); } } @@ -47,7 +47,19 @@ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition public boolean canUse(Creature caster, Skill skill, WorldObject target) { final Summon pet = caster.getPet(); - final Collection summons = caster.getServitors().values(); - return ((pet != null) && _npcIds.stream().anyMatch(npcId -> npcId == pet.getId())) || summons.stream().anyMatch(summon -> _npcIds.contains(summon.getId())); + if ((pet != null) && _npcIds.contains(pet.getId())) + { + return true; + } + + for (Summon summon : caster.getServitors().values()) + { + if (_npcIds.contains(summon.getId())) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java b/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java index 8541bc62b4..ef81b291d4 100644 --- a/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java +++ b/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,11 +30,11 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetDoorSkillCondition implements ISkillCondition { - private final List _doorIds; + private final Set _doorIds = new HashSet<>(); public OpTargetDoorSkillCondition(StatSet params) { - _doorIds = params.getList("doorIds", Integer.class); + _doorIds.addAll(params.getList("doorIds", Integer.class)); } @Override diff --git a/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java b/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java index 3ce4145703..0ccd571e19 100644 --- a/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java +++ b/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,17 +30,17 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetNpcSkillCondition implements ISkillCondition { - private final List _npcId; + private final Set _npcIds = new HashSet<>(); public OpTargetNpcSkillCondition(StatSet params) { - _npcId = params.getList("npcIds", Integer.class); + _npcIds.addAll(params.getList("npcIds", Integer.class)); } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget(); - return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId()); + return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcIds.contains(actualTarget.getId()); } } diff --git a/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/instances/AbstractInstance.java b/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/instances/AbstractInstance.java index 4b40e5f74c..ac59736fb4 100644 --- a/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/instances/AbstractInstance.java +++ b/L2J_Mobius_10.0_MasterClass/dist/game/data/scripts/instances/AbstractInstance.java @@ -16,9 +16,10 @@ */ package instances; +import java.util.HashSet; import java.util.List; +import java.util.Set; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.enums.InstanceReenterType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.instancemanager.InstanceManager; @@ -40,25 +41,29 @@ import ai.AbstractNpcAI; */ public abstract class AbstractInstance extends AbstractNpcAI { - private final int[] _templateIds; + private final Set _templateIds = new HashSet<>(); - public AbstractInstance(int... templateId) + public AbstractInstance(int... templateIds) { - if (templateId.length == 0) + if (templateIds.length == 0) { throw new IllegalStateException("No template ids were provided!"); } - _templateIds = templateId; + + for (int templateId : templateIds) + { + _templateIds.add(templateId); + } } - public int[] getTemplateId() + public Set getTemplateId() { return _templateIds; } public boolean isInInstance(Instance instance) { - return (instance != null) && CommonUtil.contains(_templateIds, instance.getTemplateId()); + return (instance != null) && _templateIds.contains(instance.getTemplateId()); } /** diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/Config.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/Config.java index 245e988ef8..d457dc03c8 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/Config.java @@ -287,7 +287,7 @@ public class Config public static boolean AUTO_LOOT_SLOT_LIMIT; public static int LOOT_RAIDS_PRIVILEGE_INTERVAL; public static int LOOT_RAIDS_PRIVILEGE_CC_SIZE; - public static List AUTO_LOOT_ITEM_IDS; + public static Set AUTO_LOOT_ITEM_IDS; public static boolean ENABLE_KEYBOARD_MOVEMENT; public static int UNSTUCK_INTERVAL; public static int TELEPORT_WATCHDOG_TIMEOUT; @@ -455,7 +455,7 @@ public class Config public static boolean ALLOW_DISCARDITEM; public static int AUTODESTROY_ITEM_AFTER; public static int HERB_AUTO_DESTROY_TIME; - public static List LIST_PROTECTED_ITEMS; + public static Set LIST_PROTECTED_ITEMS; public static boolean DATABASE_CLEAN_UP; public static int CHAR_DATA_STORE_INTERVAL; public static int CLAN_VARIABLES_STORE_INTERVAL; @@ -546,7 +546,7 @@ public class Config public static boolean ALT_OLY_LOG_FIGHTS; public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS; public static boolean ALT_OLY_ANNOUNCE_GAMES; - public static List LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(); + public static Set LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(); public static int ALT_OLY_WEAPON_ENCHANT_LIMIT; public static int ALT_OLY_ARMOR_ENCHANT_LIMIT; public static int ALT_OLY_WAIT_TIME; @@ -1251,9 +1251,9 @@ public class Config public static int AUTO_CP_PERCENTAGE; public static int AUTO_HP_PERCENTAGE; public static int AUTO_MP_PERCENTAGE; - public static List AUTO_CP_ITEM_IDS; - public static List AUTO_HP_ITEM_IDS; - public static List AUTO_MP_ITEM_IDS; + public static Set AUTO_CP_ITEM_IDS; + public static Set AUTO_HP_ITEM_IDS; + public static Set AUTO_MP_ITEM_IDS; public static boolean CUSTOM_STARTING_LOC; public static int CUSTOM_STARTING_LOC_X; public static int CUSTOM_STARTING_LOC_Y; @@ -1263,7 +1263,7 @@ public class Config public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; public static int MOB_MIN_SPAWN_RANGE; public static int MOB_MAX_SPAWN_RANGE; - public static List MOBS_LIST_NOT_RANDOM; + public static Set MOBS_LIST_NOT_RANDOM; public static boolean FREE_JUMPS_FOR_ALL; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; @@ -1282,7 +1282,7 @@ public class Config public static boolean COMMUNITY_PREMIUM_SYSTEM_ENABLED; public static int COMMUNITY_PREMIUM_COIN_ID; public static int COMMUNITY_PREMIUM_PRICE_PER_DAY; - public static List COMMUNITY_AVAILABLE_BUFFS; + public static Set COMMUNITY_AVAILABLE_BUFFS; public static Map COMMUNITY_AVAILABLE_TELEPORTS; public static boolean CUSTOM_DEPOSITABLE_ENABLED; public static boolean CUSTOM_DEPOSITABLE_QUEST_ITEMS; @@ -1947,7 +1947,7 @@ public class Config LOOT_RAIDS_PRIVILEGE_INTERVAL = characterConfig.getInt("RaidLootRightsInterval", 900) * 1000; LOOT_RAIDS_PRIVILEGE_CC_SIZE = characterConfig.getInt("RaidLootRightsCCSize", 45); final String[] autoLootItemIds = characterConfig.getString("AutoLootItemIds", "0").split(","); - AUTO_LOOT_ITEM_IDS = new ArrayList<>(autoLootItemIds.length); + AUTO_LOOT_ITEM_IDS = new HashSet<>(autoLootItemIds.length); for (String item : autoLootItemIds) { Integer itm = 0; @@ -2101,7 +2101,7 @@ public class Config AUTODESTROY_ITEM_AFTER = generalConfig.getInt("AutoDestroyDroppedItemAfter", 600); HERB_AUTO_DESTROY_TIME = generalConfig.getInt("AutoDestroyHerbTime", 60) * 1000; final String[] split = generalConfig.getString("ListOfProtectedItems", "0").split(","); - LIST_PROTECTED_ITEMS = new ArrayList<>(split.length); + LIST_PROTECTED_ITEMS = new HashSet<>(split.length); for (String id : split) { LIST_PROTECTED_ITEMS.add(Integer.parseInt(id)); @@ -2502,7 +2502,7 @@ public class Config if (!olyRestrictedItems.isEmpty()) { final String[] olyRestrictedItemsSplit = olyRestrictedItems.split(","); - LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(olyRestrictedItemsSplit.length); + LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(olyRestrictedItemsSplit.length); for (String id : olyRestrictedItemsSplit) { LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id)); @@ -2663,17 +2663,17 @@ public class Config AUTO_CP_PERCENTAGE = autoPotionsConfig.getInt("AutoCpPercentage", 70); AUTO_HP_PERCENTAGE = autoPotionsConfig.getInt("AutoHpPercentage", 70); AUTO_MP_PERCENTAGE = autoPotionsConfig.getInt("AutoMpPercentage", 70); - AUTO_CP_ITEM_IDS = new ArrayList<>(); + AUTO_CP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoCpItemIds", "0").split(",")) { AUTO_CP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_HP_ITEM_IDS = new ArrayList<>(); + AUTO_HP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoHpItemIds", "0").split(",")) { AUTO_HP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_MP_ITEM_IDS = new ArrayList<>(); + AUTO_MP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoMpItemIds", "0").split(",")) { AUTO_MP_ITEM_IDS.add(Integer.parseInt(s)); @@ -3284,7 +3284,7 @@ public class Config COMMUNITY_PREMIUM_COIN_ID = communityBoardConfig.getInt("CommunityPremiumBuyCoinId", 57); COMMUNITY_PREMIUM_PRICE_PER_DAY = communityBoardConfig.getInt("CommunityPremiumPricePerDay", 1000000); final String[] allowedBuffs = communityBoardConfig.getString("CommunityAvailableBuffs", "").split(","); - COMMUNITY_AVAILABLE_BUFFS = new ArrayList<>(allowedBuffs.length); + COMMUNITY_AVAILABLE_BUFFS = new HashSet<>(allowedBuffs.length); for (String s : allowedBuffs) { COMMUNITY_AVAILABLE_BUFFS.add(Integer.parseInt(s)); @@ -3559,7 +3559,7 @@ public class Config if (ENABLE_RANDOM_MONSTER_SPAWNS) { final String[] mobsIds = randomSpawnsConfig.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); - MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + MOBS_LIST_NOT_RANDOM = new HashSet<>(mobsIds.length); for (String id : mobsIds) { MOBS_LIST_NOT_RANDOM.add(Integer.parseInt(id)); diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java index d6e0183c6f..c3977185b4 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java @@ -202,8 +202,7 @@ public class ClanHallData implements IXmlReader final Door door = DoorData.getInstance().getDoor(doorId); for (ClanHall ch : _clanHalls.values()) { - final List doors = ch.getDoors(); - if ((doors != null) && doors.contains(door)) + if (ch.getDoors().contains(door)) { return ch; } diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java index 6aa0a1fdde..fb395b9e2d 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java @@ -17,10 +17,10 @@ package org.l2jmobius.gameserver.data.xml; import java.io.File; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -42,7 +42,7 @@ public class FakePlayerData implements IXmlReader private final Map _fakePlayerInfos = new HashMap<>(); private final Map _fakePlayerNames = new HashMap<>(); private final Map _fakePlayerIds = new HashMap<>(); - private final List _talkableFakePlayerNames = new ArrayList<>(); + private final Set _talkableFakePlayerNames = new HashSet<>(); protected FakePlayerData() { diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/data/xml/VariationData.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/data/xml/VariationData.java index c29a10baa2..079f5b3077 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/data/xml/VariationData.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/data/xml/VariationData.java @@ -20,8 +20,10 @@ import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Logger; @@ -114,14 +116,11 @@ public class VariationData implements IXmlReader }); // Support for specific item ids. - final List itemIds = new ArrayList<>(); + final Set itemIds = new HashSet<>(); forEach(categoryNode, "item", optionNode -> { final int itemId = parseInteger(optionNode.getAttributes(), "id"); - if (!itemIds.contains(itemId)) - { - itemIds.add(itemId); - } + itemIds.add(itemId); }); forEach(categoryNode, "items", optionNode -> { @@ -129,10 +128,7 @@ public class VariationData implements IXmlReader final int toId = parseInteger(optionNode.getAttributes(), "to"); for (int id = fromId; id <= toId; id++) { - if (!itemIds.contains(id)) - { - itemIds.add(id); - } + itemIds.add(id); } }); diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java index d335b95954..1122d7b9ba 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java @@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -49,7 +51,7 @@ import org.l2jmobius.gameserver.util.Util; public class SellBuffsManager implements IXmlReader { private static final Logger LOGGER = Logger.getLogger(SellBuffsManager.class.getName()); - private static final List ALLOWED_BUFFS = new ArrayList<>(); + private static final Set ALLOWED_BUFFS = new HashSet<>(); private static final String HTML_FOLDER = "data/html/mods/SellBuffs/"; protected SellBuffsManager() @@ -76,11 +78,7 @@ public class SellBuffsManager implements IXmlReader { final Element elem = (Element) node.item(i); final int skillId = Integer.parseInt(elem.getAttribute("id")); - - if (!ALLOWED_BUFFS.contains(skillId)) - { - ALLOWED_BUFFS.add(skillId); - } + ALLOWED_BUFFS.add(skillId); } } diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java index b10f75ef3d..1e45a21319 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java @@ -19,8 +19,10 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; @@ -67,7 +69,7 @@ public class WalkingManager implements IXmlReader public static final byte REPEAT_TELE_FIRST = 2; public static final byte REPEAT_RANDOM = 3; - private final List _targetedNpcIds = new ArrayList<>(); + private final Set _targetedNpcIds = new HashSet<>(); private final Map _routes = new HashMap<>(); // all available routes private final Map _activeRoutes = new HashMap<>(); // each record represents NPC, moving by predefined route from _routes, and moving progress private final Map _routesToAttach = new HashMap<>(); // each record represents NPC and all available routes for it diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/BlockList.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/BlockList.java index 1af9941ed5..9ac6266e22 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/BlockList.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/BlockList.java @@ -19,9 +19,9 @@ package org.l2jmobius.gameserver.model; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -36,10 +36,11 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; public class BlockList { private static final Logger LOGGER = Logger.getLogger(BlockList.class.getName()); - private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); + + private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); private final Player _owner; - private List _blockList; + private Set _blockList; public BlockList(Player owner) { @@ -68,9 +69,9 @@ public class BlockList OFFLINE_LIST.put(_owner.getObjectId(), _blockList); } - private static List loadList(int objId) + private static Set loadList(int objId) { - final List list = new ArrayList<>(); + final Set list = new HashSet<>(); try (Connection con = DatabaseFactory.getConnection(); PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1")) { @@ -158,7 +159,7 @@ public class BlockList _owner.setMessageRefusal(value); } - private List getBlockList() + private Set getBlockList() { return _blockList; } diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/PetData.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/PetData.java index b534c21f36..231b85e85f 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/PetData.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/PetData.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; import org.l2jmobius.gameserver.model.holders.SkillHolder; @@ -40,7 +42,7 @@ public class PetData private int _minLevel = Byte.MAX_VALUE; private int _maxLevel = 0; private boolean _syncLevel = false; - private final List _food = new ArrayList<>(); + private final Set _food = new HashSet<>(); public PetData(int npcId, int itemId) { @@ -133,7 +135,7 @@ public class PetData /** * @return the pet's food list. */ - public List getFood() + public Set getFood() { return _food; } diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/SkillLearn.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/SkillLearn.java index a69d30f105..3d5704b5f2 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/SkillLearn.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/SkillLearn.java @@ -16,9 +16,8 @@ */ package org.l2jmobius.gameserver.model; -import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashSet; -import java.util.List; import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -40,12 +39,12 @@ public class SkillLearn private final int _getDualClassLevel; private final boolean _autoGet; private final long _levelUpSp; - private final List _requiredItems = new ArrayList<>(); - private final List _races = new ArrayList<>(); - private final List _preReqSkills = new ArrayList<>(); + private final Set _requiredItems = new HashSet<>(1); + private final Set _races = EnumSet.noneOf(Race.class); + private final Set _preReqSkills = new HashSet<>(1); private SocialClass _socialClass; private final boolean _residenceSkill; - private final List _residenceIds = new ArrayList<>(); + private final Set _residenceIds = new HashSet<>(1); private final boolean _learnedByNpc; private final boolean _learnedByFS; private final Set _removeSkills = new HashSet<>(1); @@ -133,9 +132,9 @@ public class SkillLearn } /** - * @return the list with the item holders required to acquire this skill. + * @return the set with the item holders required to acquire this skill. */ - public List getRequiredItems() + public Set getRequiredItems() { return _requiredItems; } @@ -150,9 +149,9 @@ public class SkillLearn } /** - * @return a list with the races that can acquire this skill. + * @return a set with the races that can acquire this skill. */ - public List getRaces() + public Set getRaces() { return _races; } @@ -167,9 +166,9 @@ public class SkillLearn } /** - * @return the list of skill holders required to acquire this skill. + * @return the set of skill holders required to acquire this skill. */ - public List getPreReqSkills() + public Set getPreReqSkills() { return _preReqSkills; } @@ -212,9 +211,9 @@ public class SkillLearn } /** - * @return a list with the Ids where this skill is available. + * @return a set with the Ids where this skill is available. */ - public List getResidenceIds() + public Set getResidenceIds() { return _residenceIds; } diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java index a7daff9d2a..7370e093a4 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java @@ -22,7 +22,6 @@ import java.sql.ResultSet; import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.List; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; @@ -153,7 +152,7 @@ public class Pet extends Summon broadcastStatusUpdate(); - final List foodIds = getPetData().getFood(); + final Set foodIds = getPetData().getFood(); if (foodIds.isEmpty()) { if (isUncontrollable()) diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java index 9752e85090..b54396eeee 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java @@ -16,8 +16,8 @@ */ package org.l2jmobius.gameserver.model.actor.instance; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import org.l2jmobius.commons.threads.ThreadPool; @@ -57,7 +57,7 @@ public class Trap extends Npc private boolean _isTriggered; private final int _lifeTime; private Player _owner; - private final List _playersWhoDetectedMe = new ArrayList<>(); + private final Set _playersWhoDetectedMe = new HashSet<>(); private final SkillHolder _skill; private int _remainingTime; // Tasks diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java index 71ef076212..3ba8c20a9b 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor.tasks.player; -import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -69,11 +69,12 @@ public class PetFeedTask implements Runnable _player.sendPacket(SystemMessageId.YOU_ARE_OUT_OF_FEED_MOUNT_STATUS_CANCELED); } - final List foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); + final Set foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); if (foodIds.isEmpty()) { return; } + Item food = null; for (int id : foodIds) { diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java index 50d2a821c3..2611b5f121 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.actor.Creature; @@ -29,9 +29,9 @@ import org.l2jmobius.gameserver.model.zone.ZoneType; */ public class ConditionPlayerInsideZoneId extends Condition { - private final List _zones; + private final Set _zones; - public ConditionPlayerInsideZoneId(List zones) + public ConditionPlayerInsideZoneId(Set zones) { _zones = zones; } diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java index c15065eca2..d644f663f5 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Player; @@ -29,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerInstanceId extends Condition { - private final List _instanceIds; + private final Set _instanceIds; /** * Instantiates a new condition player instance id. * @param instanceIds the instance ids */ - public ConditionPlayerInstanceId(List instanceIds) + public ConditionPlayerInstanceId(Set instanceIds) { _instanceIds = instanceIds; } diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java index 14d61089ed..7c375ec45e 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -28,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerRace extends Condition { - private final Race[] _races; + private final Set _races; /** * Instantiates a new condition player race. * @param races the list containing the allowed races. */ - public ConditionPlayerRace(Race[] races) + public ConditionPlayerRace(Set races) { _races = races; } @@ -46,6 +47,6 @@ public class ConditionPlayerRace extends Condition { return false; } - return CommonUtil.contains(_races, effector.getActingPlayer().getRace()); + return _races.contains(effector.getActingPlayer().getRace()); } } diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java index 0f54766571..0b326e3f40 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId())) + if (_npcIds.contains(target.getId())) { existNpc = true; break; diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java index c5c9b5ff0e..db64b6bd7b 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromSummonedNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromSummonedNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromSummonedNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromSummonedNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId()) && (effector == target.getSummoner())) + if (_npcIds.contains(target.getId()) && (effector == target.getSummoner())) { existNpc = true; break; diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java index a3fb0f5374..a47b4b4983 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetClassIdRestriction extends Condition { - private final List _classIds; + private final Set _classIds; /** * Instantiates a new condition target class id restriction. * @param classId the class id */ - public ConditionTargetClassIdRestriction(List classId) + public ConditionTargetClassIdRestriction(Set classId) { _classIds = classId; } diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java index 82b1bd5877..9bb694f4ef 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetNpcId extends Condition { - private final List _npcIds; + private final Set _npcIds; /** * Instantiates a new condition target npc id. * @param npcIds the npc ids */ - public ConditionTargetNpcId(List npcIds) + public ConditionTargetNpcId(Set npcIds) { _npcIds = npcIds; } diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java index f26329bc21..5c86f26ae5 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.holders; -import java.util.Collection; +import java.util.Set; /** * @author Mobius @@ -25,9 +25,9 @@ public class EventDropHolder extends DropHolder { private final int _minLevel; private final int _maxLevel; - private final Collection _monsterIds; + private final Set _monsterIds; - public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Collection monsterIds) + public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Set monsterIds) { super(null, itemId, min, max, chance); _minLevel = minLevel; @@ -45,7 +45,7 @@ public class EventDropHolder extends DropHolder return _maxLevel; } - public Collection getMonsterIds() + public Set getMonsterIds() { return _monsterIds; } diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/item/Henna.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/item/Henna.java index af805ac1bc..6c2c9feea3 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/item/Henna.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/item/Henna.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model.item; import java.util.ArrayList; import java.util.EnumMap; +import java.util.EnumSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.enums.ClassId; import org.l2jmobius.gameserver.model.StatSet; @@ -42,7 +44,7 @@ public class Henna private final int _cancelCount; private final int _duration; private final List _skills; - private final List _wearClass; + private final Set _wearClass; public Henna(StatSet set) { @@ -63,7 +65,7 @@ public class Henna _cancelCount = set.getInt("cancel_count"); _duration = set.getInt("duration", -1); _skills = new ArrayList<>(); - _wearClass = new ArrayList<>(); + _wearClass = EnumSet.noneOf(ClassId.class); } /** @@ -159,7 +161,7 @@ public class Henna /** * @return the list with the allowed classes to wear this dye. */ - public List getAllowedWearClass() + public Set getAllowedWearClass() { return _wearClass; } diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java index d74b1218d3..5d694e5169 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java @@ -17,9 +17,10 @@ package org.l2jmobius.gameserver.model.item.appearance; import java.time.Duration; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.enums.Race; @@ -47,12 +48,12 @@ public class AppearanceStone private final ArmorType _armorType; private final AppearanceHandType _handType; private final AppearanceMagicType _magicType; - private List _crystalTypes; - private List _targetTypes; - private List _bodyParts; - private List _races; - private List _racesNot; - private List _allVisualIds; + private Set _crystalTypes; + private Set _targetTypes; + private Set _bodyParts; + private Set _races; + private Set _racesNot; + private Set _allVisualIds; public AppearanceStone(StatSet set) { @@ -172,35 +173,35 @@ public class AppearanceStone { if (_crystalTypes == null) { - _crystalTypes = new ArrayList<>(); + _crystalTypes = EnumSet.noneOf(CrystalType.class); } _crystalTypes.add(type); } - public List getCrystalTypes() + public Set getCrystalTypes() { - return _crystalTypes != null ? _crystalTypes : Collections.emptyList(); + return _crystalTypes != null ? _crystalTypes : Collections.emptySet(); } public void addTargetType(AppearanceTargetType type) { if (_targetTypes == null) { - _targetTypes = new ArrayList<>(); + _targetTypes = EnumSet.noneOf(AppearanceTargetType.class); } _targetTypes.add(type); } - public List getTargetTypes() + public Set getTargetTypes() { - return _targetTypes != null ? _targetTypes : Collections.emptyList(); + return _targetTypes != null ? _targetTypes : Collections.emptySet(); } public void addBodyPart(long part) { if (_bodyParts == null) { - _bodyParts = new ArrayList<>(); + _bodyParts = new HashSet<>(); } _bodyParts.add(part); } @@ -209,47 +210,47 @@ public class AppearanceStone { if (_allVisualIds == null) { - _allVisualIds = new ArrayList<>(); + _allVisualIds = new HashSet<>(); } _allVisualIds.add(appearanceHolder); } - public List getVisualIds() + public Set getVisualIds() { - return _allVisualIds != null ? _allVisualIds : Collections.emptyList(); + return _allVisualIds != null ? _allVisualIds : Collections.emptySet(); } - public List getBodyParts() + public Set getBodyParts() { - return _bodyParts != null ? _bodyParts : Collections.emptyList(); + return _bodyParts != null ? _bodyParts : Collections.emptySet(); } public void addRace(Race race) { if (_races == null) { - _races = new ArrayList<>(); + _races = EnumSet.noneOf(Race.class); } _races.add(race); } - public List getRaces() + public Set getRaces() { - return _races != null ? _races : Collections.emptyList(); + return _races != null ? _races : Collections.emptySet(); } public void addRaceNot(Race race) { if (_racesNot == null) { - _racesNot = new ArrayList<>(); + _racesNot = EnumSet.noneOf(Race.class); } _racesNot.add(race); } - public List getRacesNot() + public Set getRacesNot() { - return _racesNot != null ? _racesNot : Collections.emptyList(); + return _racesNot != null ? _racesNot : Collections.emptySet(); } /** @@ -302,7 +303,7 @@ public class AppearanceStone { // Seems like in retail item with already changed appearance, can be changed again without being restored. - final AppearanceTargetType targetType = getTargetTypes().get(0); + final AppearanceTargetType targetType = getTargetTypes().stream().findFirst().get(); switch (targetType) { case NONE: diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java index c21f776020..9af155da21 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java @@ -16,16 +16,16 @@ */ package org.l2jmobius.gameserver.model.item.enchant; +import java.util.EnumSet; +import java.util.Set; import java.util.logging.Logger; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.item.ItemTemplate; import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.model.item.type.CrystalType; import org.l2jmobius.gameserver.model.item.type.EtcItemType; -import org.l2jmobius.gameserver.model.item.type.ItemType; /** * @author UnAfraid @@ -34,28 +34,29 @@ public abstract class AbstractEnchantItem { protected static final Logger LOGGER = Logger.getLogger(AbstractEnchantItem.class.getName()); - private static final ItemType[] ENCHANT_TYPES = new ItemType[] + private static final Set ENCHANT_TYPES = EnumSet.noneOf(EtcItemType.class); + static { - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM, - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP, - EtcItemType.BLESS_ENCHT_AM, - EtcItemType.BLESS_ENCHT_AM_DOWN, - EtcItemType.BLESS_ENCHT_WP, - EtcItemType.ENCHT_AM, - EtcItemType.ENCHT_WP, - EtcItemType.ENCHT_WP_DOWN, - EtcItemType.ENCHT_AM_DOWN, - EtcItemType.GIANT_ENCHT_AM, - EtcItemType.GIANT_ENCHT_WP, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - }; + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP_DOWN); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + } private final int _id; private final CrystalType _grade; @@ -73,7 +74,7 @@ public abstract class AbstractEnchantItem { throw new NullPointerException(); } - else if (!CommonUtil.contains(ENCHANT_TYPES, getItem().getItemType())) + else if (!ENCHANT_TYPES.contains(getItem().getItemType())) { throw new IllegalAccessError(); } diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/options/OptionDataCategory.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/options/OptionDataCategory.java index dd8d1e4281..4e7856e4a2 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/options/OptionDataCategory.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/options/OptionDataCategory.java @@ -16,9 +16,9 @@ */ package org.l2jmobius.gameserver.model.options; -import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import org.l2jmobius.commons.util.Rnd; @@ -28,10 +28,10 @@ import org.l2jmobius.commons.util.Rnd; public class OptionDataCategory { private final Map _options; - private final List _itemIds; + private final Set _itemIds; private final double _chance; - public OptionDataCategory(Map options, List itemIds, double chance) + public OptionDataCategory(Map options, Set itemIds, double chance) { _options = options; _itemIds = itemIds; @@ -59,7 +59,7 @@ public class OptionDataCategory return result; } - public List getItemIds() + public Set getItemIds() { return _itemIds; } diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java index 5ba6755084..18508d0145 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java @@ -24,8 +24,10 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Set; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -184,7 +186,7 @@ public class LongTimeEvent extends Quest final Node maxLevelNode = d.getAttributes().getNamedItem("maxLevel"); final int maxLevel = maxLevelNode == null ? Integer.MAX_VALUE : Integer.parseInt(maxLevelNode.getNodeValue()); final Node monsterIdsNode = d.getAttributes().getNamedItem("monsterIds"); - final List monsterIds = new ArrayList<>(); + final Set monsterIds = new HashSet<>(); if (monsterIdsNode != null) { for (String id : monsterIdsNode.getNodeValue().split(",")) diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/residences/ClanHall.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/residences/ClanHall.java index 57aa313704..2fb931a64c 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/residences/ClanHall.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/residences/ClanHall.java @@ -23,7 +23,9 @@ import java.sql.SQLException; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -61,9 +63,9 @@ public class ClanHall extends AbstractResidence private final int _minBid; final int _lease; private final int _deposit; - private final List _npcs; - private final List _doors; - private final List _teleports; + private final Set _npcs = new HashSet<>(); + private final Set _doors = new HashSet<>(); + private final Set _teleports = new HashSet<>(); private final Location _ownerLocation; private final Location _banishLocation; // Dynamic parameters @@ -85,9 +87,21 @@ public class ClanHall extends AbstractResidence _minBid = params.getInt("minBid"); _lease = params.getInt("lease"); _deposit = params.getInt("deposit"); - _npcs = params.getList("npcList", Integer.class); - _doors = params.getList("doorList", Door.class); - _teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + final List npcs = params.getList("npcList", Integer.class); + if (npcs != null) + { + _npcs.addAll(npcs); + } + final List doors = params.getList("doorList", Door.class); + if (doors != null) + { + _doors.addAll(doors); + } + final List teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + if (teleports != null) + { + _teleports.addAll(teleports); + } _ownerLocation = params.getLocation("owner_loc"); _banishLocation = params.getLocation("banish_loc"); // Set dynamic parameters (from DB) @@ -196,7 +210,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Door} related to this {@link ClanHall}. * @return all {@link Door} related to this {@link ClanHall} */ - public List getDoors() + public Set getDoors() { return _doors; } @@ -205,7 +219,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Npc} related to this {@link ClanHall}. * @return all {@link Npc} related to this {@link ClanHall} */ - public List getNpcs() + public Set getNpcs() { return _npcs; } @@ -324,7 +338,7 @@ public class ClanHall extends AbstractResidence return _banishLocation; } - public List getTeleportList() + public Set getTeleportList() { return _teleports; } diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/siege/Castle.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/siege/Castle.java index 063570e334..27c7525c68 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/siege/Castle.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/siege/Castle.java @@ -21,8 +21,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.Calendar; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -82,7 +84,7 @@ public class Castle extends AbstractResidence private SiegeZone _zone = null; private ResidenceTeleportZone _teleZone; private Clan _formerOwner = null; - private final List _artefacts = new ArrayList<>(1); + private final Set _artefacts = new HashSet<>(1); private final Map _function = new ConcurrentHashMap<>(); private int _ticketBuyCount = 0; private boolean _isFirstMidVictory = false; @@ -1071,7 +1073,7 @@ public class Castle extends AbstractResidence _artefacts.add(artefact); } - public List getArtefacts() + public Set getArtefacts() { return _artefacts; } diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java index 0c79677eae..4ebf954ee5 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.network.serverpackets; -import java.util.List; +import java.util.Set; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.gameserver.data.sql.CharNameTable; @@ -27,19 +27,19 @@ import org.l2jmobius.gameserver.network.OutgoingPackets; */ public class BlockListPacket implements IClientOutgoingPacket { - private final List _playersId; + private final Set _playerIds; - public BlockListPacket(List playersId) + public BlockListPacket(Set playerIds) { - _playersId = playersId; + _playerIds = playerIds; } @Override public boolean write(PacketWriter packet) { OutgoingPackets.BLOCK_LIST.writeId(packet); - packet.writeD(_playersId.size()); - for (int playerId : _playersId) + packet.writeD(_playerIds.size()); + for (int playerId : _playerIds) { packet.writeS(CharNameTable.getInstance().getNameById(playerId)); packet.writeS(""); // memo ? diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java index 8555bb6e86..eb5bfd05d8 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.network.serverpackets; import java.util.List; import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; import org.l2jmobius.commons.network.PacketWriter; @@ -37,7 +38,7 @@ public class ExAcquireSkillInfo implements IClientOutgoingPacket private final int _dualClassLevel; private final long _spCost; private final int _minLevel; - private final List _itemReq; + private final Set _itemReq; private final List _skillRem; /** diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java index 84b5fead76..a163a85735 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java @@ -35,7 +35,7 @@ public class ExChooseShapeShiftingItem implements IClientOutgoingPacket public ExChooseShapeShiftingItem(AppearanceStone stone) { _type = stone.getType(); - _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().get(0); + _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().stream().findFirst().get(); _itemId = stone.getId(); } diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/util/DocumentBase.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/util/DocumentBase.java index ee1955dcf6..cd6eeb37fb 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/util/DocumentBase.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/util/DocumentBase.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.util; import java.io.File; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -392,12 +393,12 @@ public abstract class DocumentBase case "races": { final String[] racesVal = a.getNodeValue().split(","); - final Race[] races = new Race[racesVal.length]; + final Set races = EnumSet.noneOf(Race.class); for (int r = 0; r < racesVal.length; r++) { if (racesVal[r] != null) { - races[r] = Race.valueOf(racesVal[r]); + races.add(Race.valueOf(racesVal[r])); } } cond = joinAnd(cond, new ConditionPlayerRace(races)); @@ -673,13 +674,13 @@ public abstract class DocumentBase case "instanceid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final ArrayList array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInstanceId(array)); + cond = joinAnd(cond, new ConditionPlayerInstanceId(set)); break; } case "agathionid": @@ -730,10 +731,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -747,10 +748,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -836,13 +837,13 @@ public abstract class DocumentBase case "insidezoneid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInsideZoneId(array)); + cond = joinAnd(cond, new ConditionPlayerInsideZoneId(set)); break; } case "checkabnormal": @@ -975,13 +976,13 @@ public abstract class DocumentBase case "class_id_restriction": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetClassIdRestriction(array)); + cond = joinAnd(cond, new ConditionTargetClassIdRestriction(set)); break; } case "active_effect_id": @@ -1059,13 +1060,13 @@ public abstract class DocumentBase case "npcid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetNpcId(array)); + cond = joinAnd(cond, new ConditionTargetNpcId(set)); break; } case "npctype": diff --git a/L2J_Mobius_C1_HarbingersOfWar/java/org/l2jmobius/Config.java b/L2J_Mobius_C1_HarbingersOfWar/java/org/l2jmobius/Config.java index 097c1b6af8..586d1e0a13 100644 --- a/L2J_Mobius_C1_HarbingersOfWar/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_C1_HarbingersOfWar/java/org/l2jmobius/Config.java @@ -18,7 +18,7 @@ package org.l2jmobius; import java.util.Arrays; -import java.util.List; +import java.util.Set; import java.util.stream.Collectors; import org.l2jmobius.util.PropertiesParser; @@ -68,7 +68,7 @@ public class Config public static int KARMA_MAX_KARMA; public static float KARMA_LOST_MULTIPLIER; public static int KARMA_DROP_CHANCE; - public static List KARMA_PROTECTED_ITEMS; + public static Set KARMA_PROTECTED_ITEMS; // ThreadPool public static int SCHEDULED_THREAD_POOL_COUNT; public static int THREADS_PER_SCHEDULED_THREAD_POOL; @@ -117,7 +117,7 @@ public class Config KARMA_MAX_KARMA = karmaConfig.getInt("KarmaMax", 10000); KARMA_LOST_MULTIPLIER = karmaConfig.getFloat("KarmaLostMultiplier", 1); KARMA_DROP_CHANCE = karmaConfig.getInt("KarmaDropChance", 5); - KARMA_PROTECTED_ITEMS = Arrays.stream(karmaConfig.getIntArray("KarmaProtectedItems", ";")).boxed().collect(Collectors.toList()); + KARMA_PROTECTED_ITEMS.addAll(Arrays.stream(karmaConfig.getIntArray("KarmaProtectedItems", ";")).boxed().collect(Collectors.toList())); // Load threadpool config file (if exists) final PropertiesParser threadpoolConfig = new PropertiesParser(THREADPOOL_CONFIG_FILE); diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/Config.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/Config.java index d51591c611..75093f509b 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/Config.java @@ -28,9 +28,11 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -141,7 +143,7 @@ public class Config public static boolean ALLOW_MANOR; public static int AUTODESTROY_ITEM_AFTER; public static String PROTECTED_ITEMS; - public static List LIST_PROTECTED_ITEMS = new ArrayList<>(); + public static Set LIST_PROTECTED_ITEMS = new HashSet<>(); public static boolean DESTROY_DROPPED_PLAYER_ITEM; public static boolean DESTROY_EQUIPABLE_PLAYER_ITEM; public static boolean SAVE_DROPPED_ITEM; @@ -207,7 +209,7 @@ public class Config public static boolean ALLOW_WYVERN_UPGRADER; public static boolean CORRECT_PRICES; public static String NONDROPPABLE_ITEMS; - public static List LIST_NONDROPPABLE_ITEMS = new ArrayList<>(); + public static Set LIST_NONDROPPABLE_ITEMS = new HashSet<>(); public static String PET_RENT_NPC; public static List LIST_PET_RENT_NPC = new ArrayList<>(); public static boolean ENABLE_AIO_SYSTEM; @@ -338,7 +340,7 @@ public class Config public static boolean MASTERY_WEAPON_PENALTY; public static int LEVEL_TO_GET_WEAPON_PENALTY; public static boolean NPC_ATTACKABLE; - public static List INVUL_NPC_LIST; + public static Set INVUL_NPC_LIST; public static boolean DISABLE_ATTACK_NPC_TYPE; public static String ALLOWED_NPC_TYPES; public static List LIST_ALLOWED_NPC_TYPES = new ArrayList<>(); @@ -443,7 +445,7 @@ public class Config public static float CHAMPION_ATK; public static float CHAMPION_SPD_ATK; public static int CHAMPION_REWARD; - public static List CHAMPION_REWARD_ITEMS; + public static Set CHAMPION_REWARD_ITEMS; public static String CHAMP_TITLE; public static int CHAMPION_AURA; @@ -456,9 +458,9 @@ public class Config public static int AUTO_CP_PERCENTAGE; public static int AUTO_HP_PERCENTAGE; public static int AUTO_MP_PERCENTAGE; - public static List AUTO_CP_ITEM_IDS; - public static List AUTO_HP_ITEM_IDS; - public static List AUTO_MP_ITEM_IDS; + public static Set AUTO_CP_ITEM_IDS; + public static Set AUTO_HP_ITEM_IDS; + public static Set AUTO_MP_ITEM_IDS; public static boolean CUSTOM_MAIL_MANAGER_ENABLED; public static int CUSTOM_MAIL_MANAGER_DELAY; @@ -468,7 +470,7 @@ public class Config public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; public static int MOB_MIN_SPAWN_RANGE; public static int MOB_MAX_SPAWN_RANGE; - public static List MOBS_LIST_NOT_RANDOM; + public static Set MOBS_LIST_NOT_RANDOM; public static boolean ALLOW_WEDDING; public static int WEDDING_PRICE; @@ -570,7 +572,7 @@ public class Config public static boolean ALLOW_ONLINE_VIEW; public static boolean WELCOME_HTM; public static String ALLOWED_SKILLS; - public static List ALLOWED_SKILLS_LIST = new ArrayList<>(); + public static Set ALLOWED_SKILLS_LIST = new HashSet<>(); public static boolean PROTECTOR_PLAYER_PK; public static boolean PROTECTOR_PLAYER_PVP; public static int PROTECTOR_RADIUS_ACTION; @@ -633,8 +635,8 @@ public class Config public static int KARMA_PK_LIMIT; public static String KARMA_NONDROPPABLE_PET_ITEMS; public static String KARMA_NONDROPPABLE_ITEMS; - public static List KARMA_LIST_NONDROPPABLE_PET_ITEMS = new ArrayList<>(); - public static List KARMA_LIST_NONDROPPABLE_ITEMS = new ArrayList<>(); + public static Set KARMA_LIST_NONDROPPABLE_PET_ITEMS = new HashSet<>(); + public static Set KARMA_LIST_NONDROPPABLE_ITEMS = new HashSet<>(); public static int PVP_NORMAL_TIME; public static int PVP_PVP_TIME; public static boolean PVP_COLOR_SYSTEM_ENABLED; @@ -700,7 +702,7 @@ public class Config public static boolean ALT_OLY_LOG_FIGHTS; public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS; public static boolean ALT_OLY_ANNOUNCE_GAMES; - public static List LIST_OLY_RESTRICTED_SKILLS = new ArrayList<>(); + public static Set LIST_OLY_RESTRICTED_SKILLS = new HashSet<>(); public static int ALT_OLY_TELEPORT_COUNTDOWN; public static int ALT_OLY_START_TIME; public static int ALT_OLY_MIN; @@ -717,7 +719,7 @@ public class Config public static int ALT_OLY_MIN_POINT_FOR_EXCH; public static int ALT_OLY_HERO_POINTS; public static String ALT_OLY_RESTRICTED_ITEMS; - public static List LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(); + public static Set LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(); public static boolean ALLOW_EVENTS_DURING_OLY; public static boolean ALT_OLY_RECHARGE_SKILLS; public static int ALT_OLY_COMP_RITEM; @@ -813,7 +815,7 @@ public class Config public static boolean ALLOW_LETHAL_PROTECTION_MOBS; public static String LETHAL_PROTECTED_MOBS; - public static List LIST_LETHAL_PROTECTED_MOBS = new ArrayList<>(); + public static Set LIST_LETHAL_PROTECTED_MOBS = new HashSet<>(); public static float MAGIC_CRITICAL_POWER; public static float STUN_CHANCE_MODIFIER; public static float BLEED_CHANCE_MODIFIER; @@ -1281,7 +1283,7 @@ public class Config LEVEL_TO_GET_PENALTY = generalConfig.getInt("LevelToGetPenalty", 20); MASTERY_WEAPON_PENALTY = generalConfig.getBoolean("MasteryWeaponPenality", false); LEVEL_TO_GET_WEAPON_PENALTY = generalConfig.getInt("LevelToGetWeaponPenalty", 20); - INVUL_NPC_LIST = new ArrayList<>(); + INVUL_NPC_LIST = new HashSet<>(); final String t = generalConfig.getString("InvulNpcList", "30001-32132,35092-35103,35142-35146,35176-35187,35218-35232,35261-35278,35308-35319,35352-35367,35382-35407,35417-35427,35433-35469,35497-35513,35544-35587,35600-35617,35623-35628,35638-35640,35644,35645,50007,70010,99999"); String[] as; final int k = (as = t.split(",")).length; @@ -1404,7 +1406,7 @@ public class Config ALLOW_GUARDS = generalConfig.getBoolean("AllowGuards", false); AUTODESTROY_ITEM_AFTER = generalConfig.getInt("AutoDestroyDroppedItemAfter", 0); PROTECTED_ITEMS = generalConfig.getString("ListOfProtectedItems", ""); - LIST_PROTECTED_ITEMS = new ArrayList<>(); + LIST_PROTECTED_ITEMS = new HashSet<>(); for (String id : PROTECTED_ITEMS.split(",")) { LIST_PROTECTED_ITEMS.add(Integer.parseInt(id)); @@ -1569,7 +1571,7 @@ public class Config CHAMPION_ATK = championConfig.getFloat("ChampionAtk", 1f); CHAMPION_SPD_ATK = championConfig.getFloat("ChampionSpdAtk", 1f); CHAMPION_REWARD = championConfig.getInt("ChampionRewardItem", 0); - CHAMPION_REWARD_ITEMS = new ArrayList<>(); + CHAMPION_REWARD_ITEMS = new HashSet<>(); for (String s : championConfig.getString("ChampionRewardItems", "4356,10").split(";")) { if (s.isEmpty()) @@ -1598,17 +1600,17 @@ public class Config AUTO_CP_PERCENTAGE = autoPotionsConfig.getInt("AutoCpPercentage", 70); AUTO_HP_PERCENTAGE = autoPotionsConfig.getInt("AutoHpPercentage", 70); AUTO_MP_PERCENTAGE = autoPotionsConfig.getInt("AutoMpPercentage", 70); - AUTO_CP_ITEM_IDS = new ArrayList<>(); + AUTO_CP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoCpItemIds", "0").split(",")) { AUTO_CP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_HP_ITEM_IDS = new ArrayList<>(); + AUTO_HP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoHpItemIds", "0").split(",")) { AUTO_HP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_MP_ITEM_IDS = new ArrayList<>(); + AUTO_MP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoMpItemIds", "0").split(",")) { AUTO_MP_ITEM_IDS.add(Integer.parseInt(s)); @@ -1637,7 +1639,7 @@ public class Config if (ENABLE_RANDOM_MONSTER_SPAWNS) { final String[] mobsIds = randomSpawnsConfig.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); - MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + MOBS_LIST_NOT_RANDOM = new HashSet<>(mobsIds.length); for (String id : mobsIds) { MOBS_LIST_NOT_RANDOM.add(Integer.parseInt(id)); @@ -1776,7 +1778,7 @@ public class Config ALLOW_ONLINE_VIEW = customServerConfig.getBoolean("AllowOnlineView", false); KEEP_SUBCLASS_SKILLS = customServerConfig.getBoolean("KeepSubClassSkills", false); ALLOWED_SKILLS = customServerConfig.getString("AllowedSkills", "541,542,543,544,545,546,547,548,549,550,551,552,553,554,555,556,557,558,617,618,619"); - ALLOWED_SKILLS_LIST = new ArrayList<>(); + ALLOWED_SKILLS_LIST = new HashSet<>(); for (String id : ALLOWED_SKILLS.trim().split(",")) { ALLOWED_SKILLS_LIST.add(Integer.parseInt(id.trim())); @@ -1836,12 +1838,12 @@ public class Config KARMA_PK_LIMIT = pvpConfig.getInt("MinimumPKRequiredToDrop", 5); KARMA_NONDROPPABLE_PET_ITEMS = pvpConfig.getString("ListOfPetItems", "2375,3500,3501,3502,4422,4423,4424,4425,6648,6649,6650"); KARMA_NONDROPPABLE_ITEMS = pvpConfig.getString("ListOfNonDroppableItems", "57,1147,425,1146,461,10,2368,7,6,2370,2369,6842,6611,6612,6613,6614,6615,6616,6617,6618,6619,6620,6621"); - KARMA_LIST_NONDROPPABLE_PET_ITEMS = new ArrayList<>(); + KARMA_LIST_NONDROPPABLE_PET_ITEMS = new HashSet<>(); for (String id : KARMA_NONDROPPABLE_PET_ITEMS.split(",")) { KARMA_LIST_NONDROPPABLE_PET_ITEMS.add(Integer.parseInt(id)); } - KARMA_LIST_NONDROPPABLE_ITEMS = new ArrayList<>(); + KARMA_LIST_NONDROPPABLE_ITEMS = new HashSet<>(); for (String id : KARMA_NONDROPPABLE_ITEMS.split(",")) { KARMA_LIST_NONDROPPABLE_ITEMS.add(Integer.parseInt(id)); @@ -1934,7 +1936,7 @@ public class Config ALT_OLY_MIN_POINT_FOR_EXCH = olympiadConfig.getInt("AltOlyMinPointForExchange", 50); ALT_OLY_HERO_POINTS = olympiadConfig.getInt("AltOlyHeroPoints", 100); ALT_OLY_RESTRICTED_ITEMS = olympiadConfig.getString("AltOlyRestrictedItems", "0"); - LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(); + LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(); for (String id : ALT_OLY_RESTRICTED_ITEMS.split(",")) { LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id)); @@ -1946,7 +1948,7 @@ public class Config ALT_OLY_LOG_FIGHTS = olympiadConfig.getBoolean("AlyOlyLogFights", false); ALT_OLY_SHOW_MONTHLY_WINNERS = olympiadConfig.getBoolean("AltOlyShowMonthlyWinners", true); ALT_OLY_ANNOUNCE_GAMES = olympiadConfig.getBoolean("AltOlyAnnounceGames", true); - LIST_OLY_RESTRICTED_SKILLS = new ArrayList<>(); + LIST_OLY_RESTRICTED_SKILLS = new HashSet<>(); for (String id : olympiadConfig.getString("AltOlyRestrictedSkills", "0").split(",")) { LIST_OLY_RESTRICTED_SKILLS.add(Integer.parseInt(id)); @@ -2302,7 +2304,7 @@ public class Config ALLOW_RAID_LETHAL = physicsConfig.getBoolean("AllowLethalOnRaids", false); ALLOW_LETHAL_PROTECTION_MOBS = physicsConfig.getBoolean("AllowLethalProtectionMobs", false); LETHAL_PROTECTED_MOBS = physicsConfig.getString("LethalProtectedMobs", ""); - LIST_LETHAL_PROTECTED_MOBS = new ArrayList<>(); + LIST_LETHAL_PROTECTED_MOBS = new HashSet<>(); for (String id : LETHAL_PROTECTED_MOBS.split(",")) { LIST_LETHAL_PROTECTED_MOBS.add(Integer.parseInt(id)); diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/communitybbs/Manager/FriendsBBSManager.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/communitybbs/Manager/FriendsBBSManager.java index 539cf186e5..dc88a44bbe 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/communitybbs/Manager/FriendsBBSManager.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/communitybbs/Manager/FriendsBBSManager.java @@ -20,6 +20,7 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.util.ArrayList; import java.util.List; +import java.util.Set; import java.util.StringTokenizer; import org.l2jmobius.commons.database.DatabaseFactory; @@ -284,7 +285,7 @@ public class FriendsBBSManager extends BaseBBSManager } // Retrieve activeChar's blocklist and selected - final List list = activeChar.getBlockList().getBlockList(); + final Set list = activeChar.getBlockList().getBlockList(); final List slist = activeChar.getSelectedBlocksList(); final StringBuilder sb = new StringBuilder(); diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/BlockList.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/BlockList.java index dc672c934c..39f01e9b42 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/BlockList.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/BlockList.java @@ -19,10 +19,11 @@ package org.l2jmobius.gameserver.model; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.logging.Level; import java.util.logging.Logger; import org.l2jmobius.commons.database.DatabaseFactory; @@ -34,28 +35,29 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; public class BlockList { private static final Logger LOGGER = Logger.getLogger(BlockList.class.getName()); - private static Map> _offlineList = new HashMap<>(); + + private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); private final Player _owner; - private List _blockList; + private Set _blockList; public BlockList(Player owner) { _owner = owner; - _blockList = _offlineList.get(owner.getObjectId()); + _blockList = OFFLINE_LIST.get(owner.getObjectId()); if (_blockList == null) { _blockList = loadList(_owner.getObjectId()); } } - private synchronized void addToBlockList(int target) + private void addToBlockList(int target) { _blockList.add(target); updateInDB(target, true); } - private synchronized void removeFromBlockList(int target) + private void removeFromBlockList(int target) { _blockList.remove(Integer.valueOf(target)); updateInDB(target, false); @@ -63,36 +65,33 @@ public class BlockList public void playerLogout() { - _offlineList.put(_owner.getObjectId(), _blockList); + OFFLINE_LIST.put(_owner.getObjectId(), _blockList); } - private static List loadList(int objId) + private static Set loadList(int objId) { - final List list = new ArrayList<>(); - - try (Connection con = DatabaseFactory.getConnection()) + final Set list = new HashSet<>(); + try (Connection con = DatabaseFactory.getConnection(); + PreparedStatement statement = con.prepareStatement("SELECT friend_id FROM character_friends WHERE char_id=? AND relation=1")) { - final PreparedStatement statement = con.prepareStatement("SELECT friend_id FROM character_friends WHERE char_id = ? AND relation = 1"); statement.setInt(1, objId); - final ResultSet rset = statement.executeQuery(); - int friendId; - while (rset.next()) + try (ResultSet rset = statement.executeQuery()) { - friendId = rset.getInt("friend_id"); - if (friendId == objId) + int friendId; + while (rset.next()) { - continue; + friendId = rset.getInt("friend_id"); + if (friendId == objId) + { + continue; + } + list.add(friendId); } - - list.add(friendId); } - - rset.close(); - statement.close(); } catch (Exception e) { - LOGGER.warning("Error found in " + objId + " friendlist while loading BlockList: " + e.getMessage()); + LOGGER.log(Level.WARNING, "Error found in " + objId + " FriendList while loading BlockList: " + e.getMessage(), e); } return list; } @@ -101,25 +100,29 @@ public class BlockList { try (Connection con = DatabaseFactory.getConnection()) { - PreparedStatement statement; - if (state) + if (state) // add { - statement = con.prepareStatement("INSERT INTO character_friends (char_id, friend_id, relation) VALUES (?, ?, 1)"); - statement.setInt(1, _owner.getObjectId()); - statement.setInt(2, targetId); + try (PreparedStatement statement = con.prepareStatement("INSERT INTO character_friends (char_id, friend_id, relation) VALUES (?, ?, 1)")) + { + statement.setInt(1, _owner.getObjectId()); + statement.setInt(2, targetId); + statement.execute(); + } } else + // remove { - statement = con.prepareStatement("DELETE FROM character_friends WHERE char_id = ? AND friend_id = ? AND relation = 1"); - statement.setInt(1, _owner.getObjectId()); - statement.setInt(2, targetId); + try (PreparedStatement statement = con.prepareStatement("DELETE FROM character_friends WHERE char_id=? AND friend_id=? AND relation=1")) + { + statement.setInt(1, _owner.getObjectId()); + statement.setInt(2, targetId); + statement.execute(); + } } - statement.execute(); - statement.close(); } catch (Exception e) { - LOGGER.warning("Could not add/remove block player: " + e.getMessage()); + LOGGER.log(Level.WARNING, "Could not add block player: " + e.getMessage(), e); } } @@ -155,7 +158,7 @@ public class BlockList _owner.setInRefusalMode(value); } - public List getBlockList() + public Set getBlockList() { return _blockList; } @@ -239,12 +242,10 @@ public class BlockList { int i = 1; listOwner.sendPacket(SystemMessageId.IGNORE_LIST); - for (int playerId : listOwner.getBlockList().getBlockList()) { listOwner.sendMessage((i++) + ". " + CharNameTable.getInstance().getPlayerName(playerId)); } - listOwner.sendPacket(SystemMessageId.EMPTY_3); } @@ -260,12 +261,10 @@ public class BlockList { return isBlocked(player, targetId); } - - if (!_offlineList.containsKey(ownerId)) + if (!OFFLINE_LIST.containsKey(ownerId)) { - _offlineList.put(ownerId, loadList(ownerId)); + OFFLINE_LIST.put(ownerId, loadList(ownerId)); } - - return _offlineList.get(ownerId).contains(targetId); + return OFFLINE_LIST.get(ownerId).contains(targetId); } } \ No newline at end of file diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java index d7875c73a0..b3d5f2d6ad 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.holders; -import java.util.Collection; +import java.util.Set; /** * @author Mobius @@ -25,9 +25,9 @@ public class EventDropHolder extends DropHolder { private final int _minLevel; private final int _maxLevel; - private final Collection _monsterIds; + private final Set _monsterIds; - public EventDropHolder(int itemId, int min, int max, double chance, int minLevel, int maxLevel, Collection monsterIds) + public EventDropHolder(int itemId, int min, int max, double chance, int minLevel, int maxLevel, Set monsterIds) { super(itemId, min, max, chance); _minLevel = minLevel; @@ -45,7 +45,7 @@ public class EventDropHolder extends DropHolder return _maxLevel; } - public Collection getMonsterIds() + public Set getMonsterIds() { return _monsterIds; } diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java index ac5a3ba005..5acbe69ea8 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java @@ -24,8 +24,10 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Set; import java.util.logging.Level; import javax.xml.parsers.DocumentBuilder; @@ -175,7 +177,7 @@ public class LongTimeEvent extends Quest final Node maxLevelNode = d.getAttributes().getNamedItem("maxLevel"); final int maxLevel = maxLevelNode == null ? Integer.MAX_VALUE : Integer.parseInt(maxLevelNode.getNodeValue()); final Node monsterIdsNode = d.getAttributes().getNamedItem("monsterIds"); - final List monsterIds = new ArrayList<>(); + final Set monsterIds = new HashSet<>(); if (monsterIdsNode != null) { for (String id : monsterIdsNode.getNodeValue().split(",")) diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java index 24f619bb7e..7d07f62170 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java @@ -36,9 +36,11 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Enumeration; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.IntStream; @@ -157,7 +159,7 @@ public class Config public static int AUTODESTROY_ITEM_AFTER; public static int HERB_AUTO_DESTROY_TIME; public static String PROTECTED_ITEMS; - public static List LIST_PROTECTED_ITEMS = new ArrayList<>(); + public static Set LIST_PROTECTED_ITEMS = new HashSet<>(); public static boolean DESTROY_DROPPED_PLAYER_ITEM; public static boolean DESTROY_EQUIPABLE_PLAYER_ITEM; public static boolean SAVE_DROPPED_ITEM; @@ -222,7 +224,7 @@ public class Config public static boolean ALLOW_WYVERN_UPGRADER; public static boolean CORRECT_PRICES; public static String NONDROPPABLE_ITEMS; - public static List LIST_NONDROPPABLE_ITEMS = new ArrayList<>(); + public static Set LIST_NONDROPPABLE_ITEMS = new HashSet<>(); public static String PET_RENT_NPC; public static List LIST_PET_RENT_NPC = new ArrayList<>(); public static boolean ENABLE_AIO_SYSTEM; @@ -366,7 +368,7 @@ public class Config public static int LEVEL_TO_GET_WEAPON_PENALTY; public static int ACTIVE_AUGMENTS_START_REUSE_TIME; public static boolean NPC_ATTACKABLE; - public static List INVUL_NPC_LIST; + public static Set INVUL_NPC_LIST; public static boolean DISABLE_ATTACK_NPC_TYPE; public static String ALLOWED_NPC_TYPES; public static List LIST_ALLOWED_NPC_TYPES = new ArrayList<>(); @@ -471,7 +473,7 @@ public class Config public static float CHAMPION_ATK; public static float CHAMPION_SPD_ATK; public static int CHAMPION_REWARD; - public static List CHAMPION_REWARD_ITEMS; + public static Set CHAMPION_REWARD_ITEMS; public static String CHAMP_TITLE; public static int CHAMPION_AURA; @@ -484,9 +486,9 @@ public class Config public static int AUTO_CP_PERCENTAGE; public static int AUTO_HP_PERCENTAGE; public static int AUTO_MP_PERCENTAGE; - public static List AUTO_CP_ITEM_IDS; - public static List AUTO_HP_ITEM_IDS; - public static List AUTO_MP_ITEM_IDS; + public static Set AUTO_CP_ITEM_IDS; + public static Set AUTO_HP_ITEM_IDS; + public static Set AUTO_MP_ITEM_IDS; public static boolean CUSTOM_MAIL_MANAGER_ENABLED; public static int CUSTOM_MAIL_MANAGER_DELAY; @@ -496,7 +498,7 @@ public class Config public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; public static int MOB_MIN_SPAWN_RANGE; public static int MOB_MAX_SPAWN_RANGE; - public static List MOBS_LIST_NOT_RANDOM; + public static Set MOBS_LIST_NOT_RANDOM; public static boolean ALLOW_WEDDING; public static int WEDDING_PRICE; @@ -598,7 +600,7 @@ public class Config public static boolean ALLOW_ONLINE_VIEW; public static boolean WELCOME_HTM; public static String ALLOWED_SKILLS; - public static List ALLOWED_SKILLS_LIST = new ArrayList<>(); + public static Set ALLOWED_SKILLS_LIST = new HashSet<>(); public static boolean PROTECTOR_PLAYER_PK; public static boolean PROTECTOR_PLAYER_PVP; public static int PROTECTOR_RADIUS_ACTION; @@ -661,8 +663,8 @@ public class Config public static int KARMA_PK_LIMIT; public static String KARMA_NONDROPPABLE_PET_ITEMS; public static String KARMA_NONDROPPABLE_ITEMS; - public static List KARMA_LIST_NONDROPPABLE_PET_ITEMS = new ArrayList<>(); - public static List KARMA_LIST_NONDROPPABLE_ITEMS = new ArrayList<>(); + public static Set KARMA_LIST_NONDROPPABLE_PET_ITEMS = new HashSet<>(); + public static Set KARMA_LIST_NONDROPPABLE_ITEMS = new HashSet<>(); public static int PVP_NORMAL_TIME; public static int PVP_PVP_TIME; public static boolean PVP_COLOR_SYSTEM_ENABLED; @@ -728,7 +730,7 @@ public class Config public static boolean ALT_OLY_LOG_FIGHTS; public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS; public static boolean ALT_OLY_ANNOUNCE_GAMES; - public static List LIST_OLY_RESTRICTED_SKILLS = new ArrayList<>(); + public static Set LIST_OLY_RESTRICTED_SKILLS = new HashSet<>(); public static boolean ALT_OLY_AUGMENT_ALLOW; public static int ALT_OLY_TELEPORT_COUNTDOWN; public static int ALT_OLY_START_TIME; @@ -746,7 +748,7 @@ public class Config public static int ALT_OLY_MIN_POINT_FOR_EXCH; public static int ALT_OLY_HERO_POINTS; public static String ALT_OLY_RESTRICTED_ITEMS; - public static List LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(); + public static Set LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(); public static boolean ALLOW_EVENTS_DURING_OLY; public static boolean ALT_OLY_RECHARGE_SKILLS; public static int ALT_OLY_COMP_RITEM; @@ -854,7 +856,7 @@ public class Config public static boolean ALLOW_LETHAL_PROTECTION_MOBS; public static String LETHAL_PROTECTED_MOBS; - public static List LIST_LETHAL_PROTECTED_MOBS = new ArrayList<>(); + public static Set LIST_LETHAL_PROTECTED_MOBS = new HashSet<>(); public static float MAGIC_CRITICAL_POWER; public static float STUN_CHANCE_MODIFIER; public static float BLEED_CHANCE_MODIFIER; @@ -1332,7 +1334,7 @@ public class Config MASTERY_WEAPON_PENALTY = generalConfig.getBoolean("MasteryWeaponPenality", false); LEVEL_TO_GET_WEAPON_PENALTY = generalConfig.getInt("LevelToGetWeaponPenalty", 20); ACTIVE_AUGMENTS_START_REUSE_TIME = generalConfig.getInt("AugmStartReuseTime", 0); - INVUL_NPC_LIST = new ArrayList<>(); + INVUL_NPC_LIST = new HashSet<>(); final String t = generalConfig.getString("InvulNpcList", "30001-32132,35092-35103,35142-35146,35176-35187,35218-35232,35261-35278,35308-35319,35352-35367,35382-35407,35417-35427,35433-35469,35497-35513,35544-35587,35600-35617,35623-35628,35638-35640,35644,35645,50007,70010,99999"); String[] as; final int k = (as = t.split(",")).length; @@ -1456,7 +1458,7 @@ public class Config AUTODESTROY_ITEM_AFTER = generalConfig.getInt("AutoDestroyDroppedItemAfter", 0); HERB_AUTO_DESTROY_TIME = generalConfig.getInt("AutoDestroyHerbTime", 15) * 1000; PROTECTED_ITEMS = generalConfig.getString("ListOfProtectedItems", ""); - LIST_PROTECTED_ITEMS = new ArrayList<>(); + LIST_PROTECTED_ITEMS = new HashSet<>(); for (String id : PROTECTED_ITEMS.split(",")) { LIST_PROTECTED_ITEMS.add(Integer.parseInt(id)); @@ -1622,7 +1624,7 @@ public class Config CHAMPION_ATK = championConfig.getFloat("ChampionAtk", 1f); CHAMPION_SPD_ATK = championConfig.getFloat("ChampionSpdAtk", 1f); CHAMPION_REWARD = championConfig.getInt("ChampionRewardItem", 0); - CHAMPION_REWARD_ITEMS = new ArrayList<>(); + CHAMPION_REWARD_ITEMS = new HashSet<>(); for (String s : championConfig.getString("ChampionRewardItems", "4356,10").split(";")) { if (s.isEmpty()) @@ -1651,17 +1653,17 @@ public class Config AUTO_CP_PERCENTAGE = autoPotionsConfig.getInt("AutoCpPercentage", 70); AUTO_HP_PERCENTAGE = autoPotionsConfig.getInt("AutoHpPercentage", 70); AUTO_MP_PERCENTAGE = autoPotionsConfig.getInt("AutoMpPercentage", 70); - AUTO_CP_ITEM_IDS = new ArrayList<>(); + AUTO_CP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoCpItemIds", "0").split(",")) { AUTO_CP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_HP_ITEM_IDS = new ArrayList<>(); + AUTO_HP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoHpItemIds", "0").split(",")) { AUTO_HP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_MP_ITEM_IDS = new ArrayList<>(); + AUTO_MP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoMpItemIds", "0").split(",")) { AUTO_MP_ITEM_IDS.add(Integer.parseInt(s)); @@ -1690,7 +1692,7 @@ public class Config if (ENABLE_RANDOM_MONSTER_SPAWNS) { final String[] mobsIds = randomSpawnsConfig.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); - MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + MOBS_LIST_NOT_RANDOM = new HashSet<>(mobsIds.length); for (String id : mobsIds) { MOBS_LIST_NOT_RANDOM.add(Integer.parseInt(id)); @@ -1829,7 +1831,7 @@ public class Config ALLOW_ONLINE_VIEW = customServerConfig.getBoolean("AllowOnlineView", false); KEEP_SUBCLASS_SKILLS = customServerConfig.getBoolean("KeepSubClassSkills", false); ALLOWED_SKILLS = customServerConfig.getString("AllowedSkills", "541,542,543,544,545,546,547,548,549,550,551,552,553,554,555,556,557,558,617,618,619"); - ALLOWED_SKILLS_LIST = new ArrayList<>(); + ALLOWED_SKILLS_LIST = new HashSet<>(); for (String id : ALLOWED_SKILLS.trim().split(",")) { ALLOWED_SKILLS_LIST.add(Integer.parseInt(id.trim())); @@ -1889,12 +1891,12 @@ public class Config KARMA_PK_LIMIT = pvpConfig.getInt("MinimumPKRequiredToDrop", 5); KARMA_NONDROPPABLE_PET_ITEMS = pvpConfig.getString("ListOfPetItems", "2375,3500,3501,3502,4422,4423,4424,4425,6648,6649,6650"); KARMA_NONDROPPABLE_ITEMS = pvpConfig.getString("ListOfNonDroppableItems", "57,1147,425,1146,461,10,2368,7,6,2370,2369,6842,6611,6612,6613,6614,6615,6616,6617,6618,6619,6620,6621"); - KARMA_LIST_NONDROPPABLE_PET_ITEMS = new ArrayList<>(); + KARMA_LIST_NONDROPPABLE_PET_ITEMS = new HashSet<>(); for (String id : KARMA_NONDROPPABLE_PET_ITEMS.split(",")) { KARMA_LIST_NONDROPPABLE_PET_ITEMS.add(Integer.parseInt(id)); } - KARMA_LIST_NONDROPPABLE_ITEMS = new ArrayList<>(); + KARMA_LIST_NONDROPPABLE_ITEMS = new HashSet<>(); for (String id : KARMA_NONDROPPABLE_ITEMS.split(",")) { KARMA_LIST_NONDROPPABLE_ITEMS.add(Integer.parseInt(id)); @@ -1987,7 +1989,7 @@ public class Config ALT_OLY_MIN_POINT_FOR_EXCH = olympiadConfig.getInt("AltOlyMinPointForExchange", 50); ALT_OLY_HERO_POINTS = olympiadConfig.getInt("AltOlyHeroPoints", 100); ALT_OLY_RESTRICTED_ITEMS = olympiadConfig.getString("AltOlyRestrictedItems", "0"); - LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(); + LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(); for (String id : ALT_OLY_RESTRICTED_ITEMS.split(",")) { LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id)); @@ -1999,7 +2001,7 @@ public class Config ALT_OLY_LOG_FIGHTS = olympiadConfig.getBoolean("AlyOlyLogFights", false); ALT_OLY_SHOW_MONTHLY_WINNERS = olympiadConfig.getBoolean("AltOlyShowMonthlyWinners", true); ALT_OLY_ANNOUNCE_GAMES = olympiadConfig.getBoolean("AltOlyAnnounceGames", true); - LIST_OLY_RESTRICTED_SKILLS = new ArrayList<>(); + LIST_OLY_RESTRICTED_SKILLS = new HashSet<>(); for (String id : olympiadConfig.getString("AltOlyRestrictedSkills", "0").split(",")) { LIST_OLY_RESTRICTED_SKILLS.add(Integer.parseInt(id)); @@ -2368,7 +2370,7 @@ public class Config ALLOW_RAID_LETHAL = physicsConfig.getBoolean("AllowLethalOnRaids", false); ALLOW_LETHAL_PROTECTION_MOBS = physicsConfig.getBoolean("AllowLethalProtectionMobs", false); LETHAL_PROTECTED_MOBS = physicsConfig.getString("LethalProtectedMobs", ""); - LIST_LETHAL_PROTECTED_MOBS = new ArrayList<>(); + LIST_LETHAL_PROTECTED_MOBS = new HashSet<>(); for (String id : LETHAL_PROTECTED_MOBS.split(",")) { LIST_LETHAL_PROTECTED_MOBS.add(Integer.parseInt(id)); diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/communitybbs/Manager/FriendsBBSManager.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/communitybbs/Manager/FriendsBBSManager.java index 539cf186e5..dc88a44bbe 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/communitybbs/Manager/FriendsBBSManager.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/communitybbs/Manager/FriendsBBSManager.java @@ -20,6 +20,7 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.util.ArrayList; import java.util.List; +import java.util.Set; import java.util.StringTokenizer; import org.l2jmobius.commons.database.DatabaseFactory; @@ -284,7 +285,7 @@ public class FriendsBBSManager extends BaseBBSManager } // Retrieve activeChar's blocklist and selected - final List list = activeChar.getBlockList().getBlockList(); + final Set list = activeChar.getBlockList().getBlockList(); final List slist = activeChar.getSelectedBlocksList(); final StringBuilder sb = new StringBuilder(); diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/BlockList.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/BlockList.java index dc672c934c..39f01e9b42 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/BlockList.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/BlockList.java @@ -19,10 +19,11 @@ package org.l2jmobius.gameserver.model; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.logging.Level; import java.util.logging.Logger; import org.l2jmobius.commons.database.DatabaseFactory; @@ -34,28 +35,29 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; public class BlockList { private static final Logger LOGGER = Logger.getLogger(BlockList.class.getName()); - private static Map> _offlineList = new HashMap<>(); + + private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); private final Player _owner; - private List _blockList; + private Set _blockList; public BlockList(Player owner) { _owner = owner; - _blockList = _offlineList.get(owner.getObjectId()); + _blockList = OFFLINE_LIST.get(owner.getObjectId()); if (_blockList == null) { _blockList = loadList(_owner.getObjectId()); } } - private synchronized void addToBlockList(int target) + private void addToBlockList(int target) { _blockList.add(target); updateInDB(target, true); } - private synchronized void removeFromBlockList(int target) + private void removeFromBlockList(int target) { _blockList.remove(Integer.valueOf(target)); updateInDB(target, false); @@ -63,36 +65,33 @@ public class BlockList public void playerLogout() { - _offlineList.put(_owner.getObjectId(), _blockList); + OFFLINE_LIST.put(_owner.getObjectId(), _blockList); } - private static List loadList(int objId) + private static Set loadList(int objId) { - final List list = new ArrayList<>(); - - try (Connection con = DatabaseFactory.getConnection()) + final Set list = new HashSet<>(); + try (Connection con = DatabaseFactory.getConnection(); + PreparedStatement statement = con.prepareStatement("SELECT friend_id FROM character_friends WHERE char_id=? AND relation=1")) { - final PreparedStatement statement = con.prepareStatement("SELECT friend_id FROM character_friends WHERE char_id = ? AND relation = 1"); statement.setInt(1, objId); - final ResultSet rset = statement.executeQuery(); - int friendId; - while (rset.next()) + try (ResultSet rset = statement.executeQuery()) { - friendId = rset.getInt("friend_id"); - if (friendId == objId) + int friendId; + while (rset.next()) { - continue; + friendId = rset.getInt("friend_id"); + if (friendId == objId) + { + continue; + } + list.add(friendId); } - - list.add(friendId); } - - rset.close(); - statement.close(); } catch (Exception e) { - LOGGER.warning("Error found in " + objId + " friendlist while loading BlockList: " + e.getMessage()); + LOGGER.log(Level.WARNING, "Error found in " + objId + " FriendList while loading BlockList: " + e.getMessage(), e); } return list; } @@ -101,25 +100,29 @@ public class BlockList { try (Connection con = DatabaseFactory.getConnection()) { - PreparedStatement statement; - if (state) + if (state) // add { - statement = con.prepareStatement("INSERT INTO character_friends (char_id, friend_id, relation) VALUES (?, ?, 1)"); - statement.setInt(1, _owner.getObjectId()); - statement.setInt(2, targetId); + try (PreparedStatement statement = con.prepareStatement("INSERT INTO character_friends (char_id, friend_id, relation) VALUES (?, ?, 1)")) + { + statement.setInt(1, _owner.getObjectId()); + statement.setInt(2, targetId); + statement.execute(); + } } else + // remove { - statement = con.prepareStatement("DELETE FROM character_friends WHERE char_id = ? AND friend_id = ? AND relation = 1"); - statement.setInt(1, _owner.getObjectId()); - statement.setInt(2, targetId); + try (PreparedStatement statement = con.prepareStatement("DELETE FROM character_friends WHERE char_id=? AND friend_id=? AND relation=1")) + { + statement.setInt(1, _owner.getObjectId()); + statement.setInt(2, targetId); + statement.execute(); + } } - statement.execute(); - statement.close(); } catch (Exception e) { - LOGGER.warning("Could not add/remove block player: " + e.getMessage()); + LOGGER.log(Level.WARNING, "Could not add block player: " + e.getMessage(), e); } } @@ -155,7 +158,7 @@ public class BlockList _owner.setInRefusalMode(value); } - public List getBlockList() + public Set getBlockList() { return _blockList; } @@ -239,12 +242,10 @@ public class BlockList { int i = 1; listOwner.sendPacket(SystemMessageId.IGNORE_LIST); - for (int playerId : listOwner.getBlockList().getBlockList()) { listOwner.sendMessage((i++) + ". " + CharNameTable.getInstance().getPlayerName(playerId)); } - listOwner.sendPacket(SystemMessageId.EMPTY_3); } @@ -260,12 +261,10 @@ public class BlockList { return isBlocked(player, targetId); } - - if (!_offlineList.containsKey(ownerId)) + if (!OFFLINE_LIST.containsKey(ownerId)) { - _offlineList.put(ownerId, loadList(ownerId)); + OFFLINE_LIST.put(ownerId, loadList(ownerId)); } - - return _offlineList.get(ownerId).contains(targetId); + return OFFLINE_LIST.get(ownerId).contains(targetId); } } \ No newline at end of file diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java index d7875c73a0..b3d5f2d6ad 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.holders; -import java.util.Collection; +import java.util.Set; /** * @author Mobius @@ -25,9 +25,9 @@ public class EventDropHolder extends DropHolder { private final int _minLevel; private final int _maxLevel; - private final Collection _monsterIds; + private final Set _monsterIds; - public EventDropHolder(int itemId, int min, int max, double chance, int minLevel, int maxLevel, Collection monsterIds) + public EventDropHolder(int itemId, int min, int max, double chance, int minLevel, int maxLevel, Set monsterIds) { super(itemId, min, max, chance); _minLevel = minLevel; @@ -45,7 +45,7 @@ public class EventDropHolder extends DropHolder return _maxLevel; } - public Collection getMonsterIds() + public Set getMonsterIds() { return _monsterIds; } diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java index ac5a3ba005..5acbe69ea8 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java @@ -24,8 +24,10 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Set; import java.util.logging.Level; import javax.xml.parsers.DocumentBuilder; @@ -175,7 +177,7 @@ public class LongTimeEvent extends Quest final Node maxLevelNode = d.getAttributes().getNamedItem("maxLevel"); final int maxLevel = maxLevelNode == null ? Integer.MAX_VALUE : Integer.parseInt(maxLevelNode.getNodeValue()); final Node monsterIdsNode = d.getAttributes().getNamedItem("monsterIds"); - final List monsterIds = new ArrayList<>(); + final Set monsterIds = new HashSet<>(); if (monsterIdsNode != null) { for (String id : monsterIdsNode.getNodeValue().split(",")) diff --git a/L2J_Mobius_CT_2.4_Epilogue/dist/game/data/scripts/handlers/bypasshandlers/Link.java b/L2J_Mobius_CT_2.4_Epilogue/dist/game/data/scripts/handlers/bypasshandlers/Link.java index f5bfe9c8d0..419253f7dd 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/dist/game/data/scripts/handlers/bypasshandlers/Link.java +++ b/L2J_Mobius_CT_2.4_Epilogue/dist/game/data/scripts/handlers/bypasshandlers/Link.java @@ -16,7 +16,9 @@ */ package handlers.bypasshandlers; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.HashSet; +import java.util.Set; + import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.handler.IBypassHandler; import org.l2jmobius.gameserver.model.actor.Creature; @@ -31,50 +33,51 @@ public class Link implements IBypassHandler "Link" }; - private static final String[] VALID_LINKS = + private static final Set VALID_LINKS = new HashSet<>(); + static { - "adventurer_guildsman/AboutHighLevelGuilds.htm", - "adventurer_guildsman/AboutNewLifeCrystals.htm", - "clanHallDoorman/evolve.htm", - "common/augmentation_01.htm", - "common/augmentation_02.htm", - "common/crafting_01.htm", - "common/duals_01.htm", - "common/duals_02.htm", - "common/duals_03.htm", - "common/g_cube_warehouse001.htm", - "common/skill_enchant_help.htm", - "common/skill_enchant_help_01.htm", - "common/skill_enchant_help_02.htm", - "common/skill_enchant_help_03.htm", - "common/weapon_sa_01.htm", - "common/welcomeback002.htm", - "common/welcomeback003.htm", - "default/BlessingOfProtection.htm", - "default/SupportMagic.htm", - "default/SupportMagicServitor.htm", - "fisherman/fishing_championship.htm", - "fortress/foreman.htm", - "guard/kamaloka_help.htm", - "guard/kamaloka_level.htm", - "olympiad/hero_main2.htm", - "petmanager/evolve.htm", - "petmanager/exchange.htm", - "petmanager/instructions.htm", - "seven_signs/blkmrkt_1.htm", - "seven_signs/blkmrkt_2.htm", - "seven_signs/mammblack_1a.htm", - "seven_signs/mammblack_1b.htm", - "seven_signs/mammblack_1c.htm", - "seven_signs/mammblack_2a.htm", - "seven_signs/mammblack_2b.htm", - "seven_signs/mammmerch_1.htm", - "seven_signs/mammmerch_1a.htm", - "seven_signs/mammmerch_1b.htm", - "teleporter/separatedsoul.htm", - "warehouse/clanwh.htm", - "warehouse/privatewh.htm", - }; + VALID_LINKS.add("adventurer_guildsman/AboutHighLevelGuilds.htm"); + VALID_LINKS.add("adventurer_guildsman/AboutNewLifeCrystals.htm"); + VALID_LINKS.add("clanHallDoorman/evolve.htm"); + VALID_LINKS.add("common/augmentation_01.htm"); + VALID_LINKS.add("common/augmentation_02.htm"); + VALID_LINKS.add("common/crafting_01.htm"); + VALID_LINKS.add("common/duals_01.htm"); + VALID_LINKS.add("common/duals_02.htm"); + VALID_LINKS.add("common/duals_03.htm"); + VALID_LINKS.add("common/g_cube_warehouse001.htm"); + VALID_LINKS.add("common/skill_enchant_help.htm"); + VALID_LINKS.add("common/skill_enchant_help_01.htm"); + VALID_LINKS.add("common/skill_enchant_help_02.htm"); + VALID_LINKS.add("common/skill_enchant_help_03.htm"); + VALID_LINKS.add("common/weapon_sa_01.htm"); + VALID_LINKS.add("common/welcomeback002.htm"); + VALID_LINKS.add("common/welcomeback003.htm"); + VALID_LINKS.add("default/BlessingOfProtection.htm"); + VALID_LINKS.add("default/SupportMagic.htm"); + VALID_LINKS.add("default/SupportMagicServitor.htm"); + VALID_LINKS.add("fisherman/fishing_championship.htm"); + VALID_LINKS.add("fortress/foreman.htm"); + VALID_LINKS.add("guard/kamaloka_help.htm"); + VALID_LINKS.add("guard/kamaloka_level.htm"); + VALID_LINKS.add("olympiad/hero_main2.htm"); + VALID_LINKS.add("petmanager/evolve.htm"); + VALID_LINKS.add("petmanager/exchange.htm"); + VALID_LINKS.add("petmanager/instructions.htm"); + VALID_LINKS.add("seven_signs/blkmrkt_1.htm"); + VALID_LINKS.add("seven_signs/blkmrkt_2.htm"); + VALID_LINKS.add("seven_signs/mammblack_1a.htm"); + VALID_LINKS.add("seven_signs/mammblack_1b.htm"); + VALID_LINKS.add("seven_signs/mammblack_1c.htm"); + VALID_LINKS.add("seven_signs/mammblack_2a.htm"); + VALID_LINKS.add("seven_signs/mammblack_2b.htm"); + VALID_LINKS.add("seven_signs/mammmerch_1.htm"); + VALID_LINKS.add("seven_signs/mammmerch_1a.htm"); + VALID_LINKS.add("seven_signs/mammmerch_1b.htm"); + VALID_LINKS.add("teleporter/separatedsoul.htm"); + VALID_LINKS.add("warehouse/clanwh.htm"); + VALID_LINKS.add("warehouse/privatewh.htm"); + } @Override public boolean useBypass(String command, Player player, Creature target) @@ -92,12 +95,13 @@ public class Link implements IBypassHandler return false; } - String content = CommonUtil.contains(VALID_LINKS, htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; + String content = VALID_LINKS.contains(htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; // Precaution. if (htmlPath.startsWith("teleporter/") && !(player.getTarget() instanceof Teleporter)) { content = null; } + final NpcHtmlMessage html = new NpcHtmlMessage(target != null ? target.getObjectId() : 0); if (content != null) { diff --git a/L2J_Mobius_CT_2.4_Epilogue/dist/game/data/scripts/handlers/itemhandlers/PetFood.java b/L2J_Mobius_CT_2.4_Epilogue/dist/game/data/scripts/handlers/itemhandlers/PetFood.java index 3d59c30fd1..6fb310468b 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/dist/game/data/scripts/handlers/itemhandlers/PetFood.java +++ b/L2J_Mobius_CT_2.4_Epilogue/dist/game/data/scripts/handlers/itemhandlers/PetFood.java @@ -16,7 +16,7 @@ */ package handlers.itemhandlers; -import java.util.List; +import java.util.Set; import org.l2jmobius.Config; import org.l2jmobius.gameserver.data.xml.PetDataTable; @@ -82,15 +82,12 @@ public class PetFood implements IItemHandler final Player player = activeChar.getActingPlayer(); if (player.isMounted()) { - final List foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); - if (foodIds.contains(item.getId())) + final Set foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); + if (foodIds.contains(item.getId()) && player.destroyItem("Consume", item.getObjectId(), 1, null, false)) { - if (player.destroyItem("Consume", item.getObjectId(), 1, null, false)) - { - player.broadcastPacket(new MagicSkillUse(player, player, skillId, skillLevel, 0, 0)); - player.setCurrentFeed(player.getCurrentFeed() + skill.getFeed()); - return true; - } + player.broadcastPacket(new MagicSkillUse(player, player, skillId, skillLevel, 0, 0)); + player.setCurrentFeed(player.getCurrentFeed() + skill.getFeed()); + return true; } } final SystemMessage sm = new SystemMessage(SystemMessageId.S1_CANNOT_BE_USED_DUE_TO_UNSUITABLE_TERMS); diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/Config.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/Config.java index 456c708822..d3b52b70c7 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/Config.java @@ -276,7 +276,7 @@ public class Config public static boolean AUTO_LOOT_SLOT_LIMIT; public static int LOOT_RAIDS_PRIVILEGE_INTERVAL; public static int LOOT_RAIDS_PRIVILEGE_CC_SIZE; - public static List AUTO_LOOT_ITEM_IDS; + public static Set AUTO_LOOT_ITEM_IDS; public static boolean ENABLE_KEYBOARD_MOVEMENT; public static int UNSTUCK_INTERVAL; public static int TELEPORT_WATCHDOG_TIMEOUT; @@ -516,7 +516,7 @@ public class Config public static boolean ALLOW_DISCARDITEM; public static int AUTODESTROY_ITEM_AFTER; public static int HERB_AUTO_DESTROY_TIME; - public static List LIST_PROTECTED_ITEMS; + public static Set LIST_PROTECTED_ITEMS; public static boolean DATABASE_CLEAN_UP; public static int CHAR_DATA_STORE_INTERVAL; public static boolean LAZY_ITEMS_UPDATE; @@ -612,7 +612,7 @@ public class Config public static boolean ALT_OLY_LOG_FIGHTS; public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS; public static boolean ALT_OLY_ANNOUNCE_GAMES; - public static List LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(); + public static Set LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(); public static int ALT_OLY_ENCHANT_LIMIT; public static int ALT_OLY_WAIT_TIME; public static boolean ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS; @@ -1232,9 +1232,9 @@ public class Config public static int AUTO_CP_PERCENTAGE; public static int AUTO_HP_PERCENTAGE; public static int AUTO_MP_PERCENTAGE; - public static List AUTO_CP_ITEM_IDS; - public static List AUTO_HP_ITEM_IDS; - public static List AUTO_MP_ITEM_IDS; + public static Set AUTO_CP_ITEM_IDS; + public static Set AUTO_HP_ITEM_IDS; + public static Set AUTO_MP_ITEM_IDS; public static boolean CUSTOM_STARTING_LOC; public static int CUSTOM_STARTING_LOC_X; public static int CUSTOM_STARTING_LOC_Y; @@ -1244,7 +1244,7 @@ public class Config public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; public static int MOB_MIN_SPAWN_RANGE; public static int MOB_MAX_SPAWN_RANGE; - public static List MOBS_LIST_NOT_RANDOM; + public static Set MOBS_LIST_NOT_RANDOM; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; public static boolean COMMUNITYBOARD_ENABLE_MULTISELLS; @@ -1262,7 +1262,7 @@ public class Config public static boolean COMMUNITY_PREMIUM_SYSTEM_ENABLED; public static int COMMUNITY_PREMIUM_COIN_ID; public static int COMMUNITY_PREMIUM_PRICE_PER_DAY; - public static List COMMUNITY_AVAILABLE_BUFFS; + public static Set COMMUNITY_AVAILABLE_BUFFS; public static Map COMMUNITY_AVAILABLE_TELEPORTS; public static boolean CUSTOM_MAIL_MANAGER_ENABLED; public static int CUSTOM_MAIL_MANAGER_DELAY; @@ -1933,7 +1933,7 @@ public class Config LOOT_RAIDS_PRIVILEGE_INTERVAL = characterConfig.getInt("RaidLootRightsInterval", 900) * 1000; LOOT_RAIDS_PRIVILEGE_CC_SIZE = characterConfig.getInt("RaidLootRightsCCSize", 45); final String[] autoLootItemIds = characterConfig.getString("AutoLootItemIds", "0").split(","); - AUTO_LOOT_ITEM_IDS = new ArrayList<>(autoLootItemIds.length); + AUTO_LOOT_ITEM_IDS = new HashSet<>(autoLootItemIds.length); for (String item : autoLootItemIds) { Integer itm = 0; @@ -2044,7 +2044,7 @@ public class Config AUTODESTROY_ITEM_AFTER = generalConfig.getInt("AutoDestroyDroppedItemAfter", 600); HERB_AUTO_DESTROY_TIME = generalConfig.getInt("AutoDestroyHerbTime", 60) * 1000; final String[] split = generalConfig.getString("ListOfProtectedItems", "0").split(","); - LIST_PROTECTED_ITEMS = new ArrayList<>(split.length); + LIST_PROTECTED_ITEMS = new HashSet<>(split.length); for (String id : split) { LIST_PROTECTED_ITEMS.add(Integer.parseInt(id)); @@ -2477,7 +2477,7 @@ public class Config if (!olyRestrictedItems.isEmpty()) { final String[] olyRestrictedItemsSplit = olyRestrictedItems.split(","); - LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(olyRestrictedItemsSplit.length); + LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(olyRestrictedItemsSplit.length); for (String id : olyRestrictedItemsSplit) { LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id)); @@ -2625,17 +2625,17 @@ public class Config AUTO_CP_PERCENTAGE = autoPotionsConfig.getInt("AutoCpPercentage", 70); AUTO_HP_PERCENTAGE = autoPotionsConfig.getInt("AutoHpPercentage", 70); AUTO_MP_PERCENTAGE = autoPotionsConfig.getInt("AutoMpPercentage", 70); - AUTO_CP_ITEM_IDS = new ArrayList<>(); + AUTO_CP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoCpItemIds", "0").split(",")) { AUTO_CP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_HP_ITEM_IDS = new ArrayList<>(); + AUTO_HP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoHpItemIds", "0").split(",")) { AUTO_HP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_MP_ITEM_IDS = new ArrayList<>(); + AUTO_MP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoMpItemIds", "0").split(",")) { AUTO_MP_ITEM_IDS.add(Integer.parseInt(s)); @@ -2739,7 +2739,7 @@ public class Config COMMUNITY_PREMIUM_COIN_ID = communityBoardConfig.getInt("CommunityPremiumBuyCoinId", 57); COMMUNITY_PREMIUM_PRICE_PER_DAY = communityBoardConfig.getInt("CommunityPremiumPricePerDay", 1000000); final String[] allowedBuffs = communityBoardConfig.getString("CommunityAvailableBuffs", "").split(","); - COMMUNITY_AVAILABLE_BUFFS = new ArrayList<>(allowedBuffs.length); + COMMUNITY_AVAILABLE_BUFFS = new HashSet<>(allowedBuffs.length); for (String s : allowedBuffs) { COMMUNITY_AVAILABLE_BUFFS.add(Integer.parseInt(s)); @@ -3008,7 +3008,7 @@ public class Config if (ENABLE_RANDOM_MONSTER_SPAWNS) { final String[] mobsIds = randomSpawnsConfig.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); - MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + MOBS_LIST_NOT_RANDOM = new HashSet<>(mobsIds.length); for (String id : mobsIds) { MOBS_LIST_NOT_RANDOM.add(Integer.parseInt(id)); diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java index 6aa0a1fdde..fb395b9e2d 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java @@ -17,10 +17,10 @@ package org.l2jmobius.gameserver.data.xml; import java.io.File; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -42,7 +42,7 @@ public class FakePlayerData implements IXmlReader private final Map _fakePlayerInfos = new HashMap<>(); private final Map _fakePlayerNames = new HashMap<>(); private final Map _fakePlayerIds = new HashMap<>(); - private final List _talkableFakePlayerNames = new ArrayList<>(); + private final Set _talkableFakePlayerNames = new HashSet<>(); protected FakePlayerData() { diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/data/xml/SkillTreeData.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/data/xml/SkillTreeData.java index 91aeb0879a..c92b0f5726 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/data/xml/SkillTreeData.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/data/xml/SkillTreeData.java @@ -41,8 +41,8 @@ import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.enums.SocialClass; import org.l2jmobius.gameserver.model.SkillLearn; import org.l2jmobius.gameserver.model.SkillLearn.SubClassData; -import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.model.clan.Clan; import org.l2jmobius.gameserver.model.holders.ItemHolder; import org.l2jmobius.gameserver.model.holders.PlayerSkillHolder; diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java index a16cdfcbef..e44cc7f693 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java @@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -49,7 +51,7 @@ import org.l2jmobius.gameserver.util.Util; public class SellBuffsManager implements IXmlReader { private static final Logger LOGGER = Logger.getLogger(SellBuffsManager.class.getName()); - private static final List ALLOWED_BUFFS = new ArrayList<>(); + private static final Set ALLOWED_BUFFS = new HashSet<>(); private static final String HTML_FOLDER = "data/html/mods/SellBuffs/"; protected SellBuffsManager() @@ -76,11 +78,7 @@ public class SellBuffsManager implements IXmlReader { final Element elem = (Element) node.item(i); final int skillId = Integer.parseInt(elem.getAttribute("id")); - - if (!ALLOWED_BUFFS.contains(skillId)) - { - ALLOWED_BUFFS.add(skillId); - } + ALLOWED_BUFFS.add(skillId); } } diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java index b10f75ef3d..1e45a21319 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java @@ -19,8 +19,10 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; @@ -67,7 +69,7 @@ public class WalkingManager implements IXmlReader public static final byte REPEAT_TELE_FIRST = 2; public static final byte REPEAT_RANDOM = 3; - private final List _targetedNpcIds = new ArrayList<>(); + private final Set _targetedNpcIds = new HashSet<>(); private final Map _routes = new HashMap<>(); // all available routes private final Map _activeRoutes = new HashMap<>(); // each record represents NPC, moving by predefined route from _routes, and moving progress private final Map _routesToAttach = new HashMap<>(); // each record represents NPC and all available routes for it diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/BlockList.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/BlockList.java index 886a920fff..e484567678 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/BlockList.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/BlockList.java @@ -19,9 +19,9 @@ package org.l2jmobius.gameserver.model; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -35,10 +35,11 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; public class BlockList { private static final Logger LOGGER = Logger.getLogger(BlockList.class.getName()); - private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); + + private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); private final Player _owner; - private List _blockList; + private Set _blockList; public BlockList(Player owner) { @@ -67,9 +68,9 @@ public class BlockList OFFLINE_LIST.put(_owner.getObjectId(), _blockList); } - private static List loadList(int objId) + private static Set loadList(int objId) { - final List list = new ArrayList<>(); + final Set list = new HashSet<>(); try (Connection con = DatabaseFactory.getConnection(); PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1")) { @@ -157,7 +158,7 @@ public class BlockList _owner.setMessageRefusal(value); } - private List getBlockList() + private Set getBlockList() { return _blockList; } diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/PetData.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/PetData.java index 877b1b7703..b2a937de45 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/PetData.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/PetData.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; import org.l2jmobius.gameserver.model.holders.SkillHolder; @@ -39,7 +41,7 @@ public class PetData private int _hungryLimit = 1; private int _minLevel = Byte.MAX_VALUE; private boolean _syncLevel = false; - private final List _food = new ArrayList<>(); + private final Set _food = new HashSet<>(); public PetData(int npcId, int itemId) { @@ -120,7 +122,7 @@ public class PetData /** * @return the pet's food list. */ - public List getFood() + public Set getFood() { return _food; } diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/SkillLearn.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/SkillLearn.java index 4b03bcf359..3949ef0eab 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/SkillLearn.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/SkillLearn.java @@ -17,7 +17,10 @@ package org.l2jmobius.gameserver.model; import java.util.ArrayList; +import java.util.EnumSet; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.Config; import org.l2jmobius.gameserver.enums.ClassId; @@ -37,13 +40,13 @@ public class SkillLearn private final int _getLevel; private final boolean _autoGet; private final int _levelUpSp; - private final List _requiredItems = new ArrayList<>(); - private final List _races = new ArrayList<>(); - private final List _preReqSkills = new ArrayList<>(); + private final Set _requiredItems = new HashSet<>(1); + private final Set _races = EnumSet.noneOf(Race.class); + private final Set _preReqSkills = new HashSet<>(1); private SocialClass _socialClass; private final boolean _residenceSkill; - private final List _residenceIds = new ArrayList<>(); - private final List _subClassLvlNumber = new ArrayList<>(); + private final Set _residenceIds = new HashSet<>(1); + private final List _subClassLvlNumber = new ArrayList<>(1); private final boolean _learnedByNpc; private final boolean _learnedByFS; @@ -141,9 +144,9 @@ public class SkillLearn } /** - * @return the list with the item holders required to acquire this skill. + * @return the set with the item holders required to acquire this skill. */ - public List getRequiredItems() + public Set getRequiredItems() { return _requiredItems; } @@ -158,9 +161,9 @@ public class SkillLearn } /** - * @return a list with the races that can acquire this skill. + * @return a set with the races that can acquire this skill. */ - public List getRaces() + public Set getRaces() { return _races; } @@ -175,9 +178,9 @@ public class SkillLearn } /** - * @return the list of skill holders required to acquire this skill. + * @return the set of skill holders required to acquire this skill. */ - public List getPreReqSkills() + public Set getPreReqSkills() { return _preReqSkills; } @@ -220,9 +223,9 @@ public class SkillLearn } /** - * @return a list with the Ids where this skill is available. + * @return a set with the Ids where this skill is available. */ - public List getResidenceIds() + public Set getResidenceIds() { return _residenceIds; } diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java index 13bffc0c4e..4dba093df8 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java @@ -21,6 +21,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.LinkedList; import java.util.List; +import java.util.Set; import java.util.concurrent.Future; import java.util.logging.Level; import java.util.logging.Logger; @@ -172,7 +173,7 @@ public class Pet extends Summon setCurrentFed(_curFed > getFeedConsume() ? _curFed - getFeedConsume() : 0); broadcastStatusUpdate(); - final List foodIds = getPetData().getFood(); + final Set foodIds = getPetData().getFood(); if (foodIds.isEmpty()) { if (isUncontrollable()) diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java index e72f815864..5bce7e4fc9 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java @@ -16,8 +16,8 @@ */ package org.l2jmobius.gameserver.model.actor.instance; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import org.l2jmobius.commons.threads.ThreadPool; @@ -57,7 +57,7 @@ public class Trap extends Npc private boolean _isTriggered; private final int _lifeTime; private Player _owner; - private final List _playersWhoDetectedMe = new ArrayList<>(); + private final Set _playersWhoDetectedMe = new HashSet<>(); private final SkillHolder _skill; private int _remainingTime; // Tasks diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java index 52626d9b27..a819aaa917 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor.tasks.player; -import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -69,7 +69,7 @@ public class PetFeedTask implements Runnable return; } - final List foodIds = PetDataTable.getInstance().getPetData(_player.getMountNpcId()).getFood(); + final Set foodIds = PetDataTable.getInstance().getPetData(_player.getMountNpcId()).getFood(); if (foodIds.isEmpty()) { return; diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java index 50d2a821c3..2611b5f121 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.actor.Creature; @@ -29,9 +29,9 @@ import org.l2jmobius.gameserver.model.zone.ZoneType; */ public class ConditionPlayerInsideZoneId extends Condition { - private final List _zones; + private final Set _zones; - public ConditionPlayerInsideZoneId(List zones) + public ConditionPlayerInsideZoneId(Set zones) { _zones = zones; } diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java index 40ac9d5ebd..b9db8f8c40 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.instancemanager.InstanceManager; import org.l2jmobius.gameserver.model.actor.Creature; @@ -29,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerInstanceId extends Condition { - private final List _instanceIds; + private final Set _instanceIds; /** * Instantiates a new condition player instance id. * @param instanceIds the instance ids */ - public ConditionPlayerInstanceId(List instanceIds) + public ConditionPlayerInstanceId(Set instanceIds) { _instanceIds = instanceIds; } diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java index 0fbb77301a..7c375ec45e 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -28,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerRace extends Condition { - private final Race[] _races; + private final Set _races; /** * Instantiates a new condition player race. * @param races the list containing the allowed races. */ - public ConditionPlayerRace(Race[] races) + public ConditionPlayerRace(Set races) { _races = races; } @@ -42,6 +43,10 @@ public class ConditionPlayerRace extends Condition @Override public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { - return (effector != null) && effector.isPlayer() && CommonUtil.contains(_races, effector.getActingPlayer().getRace()); + if ((effector == null) || !effector.isPlayer()) + { + return false; + } + return _races.contains(effector.getActingPlayer().getRace()); } } diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java index 0f54766571..0b326e3f40 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId())) + if (_npcIds.contains(target.getId())) { existNpc = true; break; diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java index 161164ed30..78c281e88a 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetClassIdRestriction extends Condition { - private final List _classIds; + private final Set _classIds; /** * Instantiates a new condition target class id restriction. * @param classId the class id */ - public ConditionTargetClassIdRestriction(List classId) + public ConditionTargetClassIdRestriction(Set classId) { _classIds = classId; } diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java index 7de1f3b20a..c723f58d10 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; @@ -28,13 +28,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetNpcId extends Condition { - private final List _npcIds; + private final Set _npcIds; /** * Instantiates a new condition target npc id. * @param npcIds the npc ids */ - public ConditionTargetNpcId(List npcIds) + public ConditionTargetNpcId(Set npcIds) { _npcIds = npcIds; } diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java index f26329bc21..5c86f26ae5 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.holders; -import java.util.Collection; +import java.util.Set; /** * @author Mobius @@ -25,9 +25,9 @@ public class EventDropHolder extends DropHolder { private final int _minLevel; private final int _maxLevel; - private final Collection _monsterIds; + private final Set _monsterIds; - public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Collection monsterIds) + public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Set monsterIds) { super(null, itemId, min, max, chance); _minLevel = minLevel; @@ -45,7 +45,7 @@ public class EventDropHolder extends DropHolder return _maxLevel; } - public Collection getMonsterIds() + public Set getMonsterIds() { return _monsterIds; } diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/item/Henna.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/item/Henna.java index 65a4b9fb37..de64df91e0 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/item/Henna.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/item/Henna.java @@ -16,8 +16,9 @@ */ package org.l2jmobius.gameserver.model.item; -import java.util.ArrayList; +import java.util.EnumSet; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.enums.ClassId; import org.l2jmobius.gameserver.model.StatSet; @@ -40,7 +41,7 @@ public class Henna private final int _wearCount; private final int _cancelFee; private final int _cancelCount; - private final List _wearClass; + private final Set _wearClass; public Henna(StatSet set) { @@ -56,7 +57,7 @@ public class Henna _wearCount = set.getInt("wear_count"); _cancelFee = set.getInt("cancel_fee"); _cancelCount = set.getInt("cancel_count"); - _wearClass = new ArrayList<>(); + _wearClass = EnumSet.noneOf(ClassId.class); } /** @@ -158,7 +159,7 @@ public class Henna /** * @return the list with the allowed classes to wear this dye. */ - public List getAllowedWearClass() + public Set getAllowedWearClass() { return _wearClass; } diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java index f9c744cc8e..38ebbfbd3a 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java @@ -16,16 +16,16 @@ */ package org.l2jmobius.gameserver.model.item.enchant; +import java.util.EnumSet; +import java.util.Set; import java.util.logging.Logger; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.item.ItemTemplate; import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.model.item.type.CrystalType; import org.l2jmobius.gameserver.model.item.type.EtcItemType; -import org.l2jmobius.gameserver.model.item.type.ItemType; /** * @author UnAfraid @@ -34,17 +34,18 @@ public abstract class AbstractEnchantItem { protected static final Logger LOGGER = Logger.getLogger(AbstractEnchantItem.class.getName()); - private static final ItemType[] ENCHANT_TYPES = new ItemType[] + private static final Set ENCHANT_TYPES = EnumSet.noneOf(EtcItemType.class); + static { - EtcItemType.ANCIENT_CRYSTAL_ENCHANT_AM, - EtcItemType.ANCIENT_CRYSTAL_ENCHANT_WP, - EtcItemType.BLESS_SCRL_ENCHANT_AM, - EtcItemType.BLESS_SCRL_ENCHANT_WP, - EtcItemType.SCRL_ENCHANT_AM, - EtcItemType.SCRL_ENCHANT_WP, - EtcItemType.SCRL_INC_ENCHANT_PROP_AM, - EtcItemType.SCRL_INC_ENCHANT_PROP_WP, - }; + ENCHANT_TYPES.add(EtcItemType.ANCIENT_CRYSTAL_ENCHANT_AM); + ENCHANT_TYPES.add(EtcItemType.ANCIENT_CRYSTAL_ENCHANT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESS_SCRL_ENCHANT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESS_SCRL_ENCHANT_WP); + ENCHANT_TYPES.add(EtcItemType.SCRL_ENCHANT_AM); + ENCHANT_TYPES.add(EtcItemType.SCRL_ENCHANT_WP); + ENCHANT_TYPES.add(EtcItemType.SCRL_INC_ENCHANT_PROP_AM); + ENCHANT_TYPES.add(EtcItemType.SCRL_INC_ENCHANT_PROP_WP); + } private final int _id; private final CrystalType _grade; @@ -58,7 +59,7 @@ public abstract class AbstractEnchantItem { throw new NullPointerException(); } - else if (!CommonUtil.contains(ENCHANT_TYPES, getItem().getItemType())) + else if (!ENCHANT_TYPES.contains(getItem().getItemType())) { throw new IllegalAccessError(); } @@ -146,7 +147,7 @@ public abstract class AbstractEnchantItem * @param type2 * @return {@code true} if current type2 is valid to be enchanted, {@code false} otherwise */ - private final boolean isValidItemType(int type2) + private boolean isValidItemType(int type2) { if (type2 == ItemTemplate.TYPE2_WEAPON) { diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java index 418d641a31..bba81ea0be 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java @@ -24,8 +24,10 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Set; import java.util.logging.Level; import javax.xml.parsers.DocumentBuilder; @@ -175,7 +177,7 @@ public class LongTimeEvent extends Quest final Node maxLevelNode = d.getAttributes().getNamedItem("maxLevel"); final int maxLevel = maxLevelNode == null ? Integer.MAX_VALUE : Integer.parseInt(maxLevelNode.getNodeValue()); final Node monsterIdsNode = d.getAttributes().getNamedItem("monsterIds"); - final List monsterIds = new ArrayList<>(); + final Set monsterIds = new HashSet<>(); if (monsterIdsNode != null) { for (String id : monsterIdsNode.getNodeValue().split(",")) diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/siege/Castle.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/siege/Castle.java index aeffed81cb..cc4d62eb7a 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/siege/Castle.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/siege/Castle.java @@ -21,8 +21,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.Calendar; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -78,8 +80,8 @@ public class Castle extends AbstractResidence private SiegeZone _zone = null; private ResidenceTeleportZone _teleZone; private Clan _formerOwner = null; - private final List _artefacts = new ArrayList<>(1); - private final Map _function; + private final Set _artefacts = new HashSet<>(1); + private final Map _function = new ConcurrentHashMap<>(); private int _ticketBuyCount = 0; private boolean _isFirstMidVictory = false; @@ -237,10 +239,6 @@ public class Castle extends AbstractResidence { super(castleId); load(); - /* - * if (getResidenceId() == 7 || castleId == 9) // Goddard and Schuttgart _nbArtifact = 2; - */ - _function = new ConcurrentHashMap<>(); initResidenceZone(); if (_ownerId != 0) { @@ -1075,7 +1073,7 @@ public class Castle extends AbstractResidence _artefacts.add(artefact); } - public List getArtefacts() + public Set getArtefacts() { return _artefacts; } diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/util/DocumentBase.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/util/DocumentBase.java index cb42fd94ff..e48286b1ba 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/util/DocumentBase.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/util/DocumentBase.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.util; import java.io.File; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -476,12 +477,12 @@ public abstract class DocumentBase case "races": { final String[] racesVal = a.getNodeValue().split(","); - final Race[] races = new Race[racesVal.length]; + final Set races = EnumSet.noneOf(Race.class); for (int r = 0; r < racesVal.length; r++) { if (racesVal[r] != null) { - races[r] = Race.valueOf(racesVal[r]); + races.add(Race.valueOf(racesVal[r])); } } cond = joinAnd(cond, new ConditionPlayerRace(races)); @@ -752,13 +753,13 @@ public abstract class DocumentBase case "instanceid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionPlayerInstanceId(array)); + cond = joinAnd(cond, new ConditionPlayerInstanceId(set)); break; } case "agathionid": @@ -803,10 +804,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -882,13 +883,13 @@ public abstract class DocumentBase case "insidezoneid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionPlayerInsideZoneId(array)); + cond = joinAnd(cond, new ConditionPlayerInsideZoneId(set)); break; } case "checkabnormal": @@ -978,13 +979,13 @@ public abstract class DocumentBase case "class_id_restriction": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetClassIdRestriction(array)); + cond = joinAnd(cond, new ConditionTargetClassIdRestriction(set)); break; } case "active_effect_id": @@ -1062,13 +1063,13 @@ public abstract class DocumentBase case "npcid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetNpcId(array)); + cond = joinAnd(cond, new ConditionTargetNpcId(set)); break; } case "npctype": diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/bypasshandlers/Link.java b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/bypasshandlers/Link.java index f5bfe9c8d0..419253f7dd 100644 --- a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/bypasshandlers/Link.java +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/bypasshandlers/Link.java @@ -16,7 +16,9 @@ */ package handlers.bypasshandlers; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.HashSet; +import java.util.Set; + import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.handler.IBypassHandler; import org.l2jmobius.gameserver.model.actor.Creature; @@ -31,50 +33,51 @@ public class Link implements IBypassHandler "Link" }; - private static final String[] VALID_LINKS = + private static final Set VALID_LINKS = new HashSet<>(); + static { - "adventurer_guildsman/AboutHighLevelGuilds.htm", - "adventurer_guildsman/AboutNewLifeCrystals.htm", - "clanHallDoorman/evolve.htm", - "common/augmentation_01.htm", - "common/augmentation_02.htm", - "common/crafting_01.htm", - "common/duals_01.htm", - "common/duals_02.htm", - "common/duals_03.htm", - "common/g_cube_warehouse001.htm", - "common/skill_enchant_help.htm", - "common/skill_enchant_help_01.htm", - "common/skill_enchant_help_02.htm", - "common/skill_enchant_help_03.htm", - "common/weapon_sa_01.htm", - "common/welcomeback002.htm", - "common/welcomeback003.htm", - "default/BlessingOfProtection.htm", - "default/SupportMagic.htm", - "default/SupportMagicServitor.htm", - "fisherman/fishing_championship.htm", - "fortress/foreman.htm", - "guard/kamaloka_help.htm", - "guard/kamaloka_level.htm", - "olympiad/hero_main2.htm", - "petmanager/evolve.htm", - "petmanager/exchange.htm", - "petmanager/instructions.htm", - "seven_signs/blkmrkt_1.htm", - "seven_signs/blkmrkt_2.htm", - "seven_signs/mammblack_1a.htm", - "seven_signs/mammblack_1b.htm", - "seven_signs/mammblack_1c.htm", - "seven_signs/mammblack_2a.htm", - "seven_signs/mammblack_2b.htm", - "seven_signs/mammmerch_1.htm", - "seven_signs/mammmerch_1a.htm", - "seven_signs/mammmerch_1b.htm", - "teleporter/separatedsoul.htm", - "warehouse/clanwh.htm", - "warehouse/privatewh.htm", - }; + VALID_LINKS.add("adventurer_guildsman/AboutHighLevelGuilds.htm"); + VALID_LINKS.add("adventurer_guildsman/AboutNewLifeCrystals.htm"); + VALID_LINKS.add("clanHallDoorman/evolve.htm"); + VALID_LINKS.add("common/augmentation_01.htm"); + VALID_LINKS.add("common/augmentation_02.htm"); + VALID_LINKS.add("common/crafting_01.htm"); + VALID_LINKS.add("common/duals_01.htm"); + VALID_LINKS.add("common/duals_02.htm"); + VALID_LINKS.add("common/duals_03.htm"); + VALID_LINKS.add("common/g_cube_warehouse001.htm"); + VALID_LINKS.add("common/skill_enchant_help.htm"); + VALID_LINKS.add("common/skill_enchant_help_01.htm"); + VALID_LINKS.add("common/skill_enchant_help_02.htm"); + VALID_LINKS.add("common/skill_enchant_help_03.htm"); + VALID_LINKS.add("common/weapon_sa_01.htm"); + VALID_LINKS.add("common/welcomeback002.htm"); + VALID_LINKS.add("common/welcomeback003.htm"); + VALID_LINKS.add("default/BlessingOfProtection.htm"); + VALID_LINKS.add("default/SupportMagic.htm"); + VALID_LINKS.add("default/SupportMagicServitor.htm"); + VALID_LINKS.add("fisherman/fishing_championship.htm"); + VALID_LINKS.add("fortress/foreman.htm"); + VALID_LINKS.add("guard/kamaloka_help.htm"); + VALID_LINKS.add("guard/kamaloka_level.htm"); + VALID_LINKS.add("olympiad/hero_main2.htm"); + VALID_LINKS.add("petmanager/evolve.htm"); + VALID_LINKS.add("petmanager/exchange.htm"); + VALID_LINKS.add("petmanager/instructions.htm"); + VALID_LINKS.add("seven_signs/blkmrkt_1.htm"); + VALID_LINKS.add("seven_signs/blkmrkt_2.htm"); + VALID_LINKS.add("seven_signs/mammblack_1a.htm"); + VALID_LINKS.add("seven_signs/mammblack_1b.htm"); + VALID_LINKS.add("seven_signs/mammblack_1c.htm"); + VALID_LINKS.add("seven_signs/mammblack_2a.htm"); + VALID_LINKS.add("seven_signs/mammblack_2b.htm"); + VALID_LINKS.add("seven_signs/mammmerch_1.htm"); + VALID_LINKS.add("seven_signs/mammmerch_1a.htm"); + VALID_LINKS.add("seven_signs/mammmerch_1b.htm"); + VALID_LINKS.add("teleporter/separatedsoul.htm"); + VALID_LINKS.add("warehouse/clanwh.htm"); + VALID_LINKS.add("warehouse/privatewh.htm"); + } @Override public boolean useBypass(String command, Player player, Creature target) @@ -92,12 +95,13 @@ public class Link implements IBypassHandler return false; } - String content = CommonUtil.contains(VALID_LINKS, htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; + String content = VALID_LINKS.contains(htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; // Precaution. if (htmlPath.startsWith("teleporter/") && !(player.getTarget() instanceof Teleporter)) { content = null; } + final NpcHtmlMessage html = new NpcHtmlMessage(target != null ? target.getObjectId() : 0); if (content != null) { diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/itemhandlers/PetFood.java b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/itemhandlers/PetFood.java index 3d59c30fd1..6fb310468b 100644 --- a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/itemhandlers/PetFood.java +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/itemhandlers/PetFood.java @@ -16,7 +16,7 @@ */ package handlers.itemhandlers; -import java.util.List; +import java.util.Set; import org.l2jmobius.Config; import org.l2jmobius.gameserver.data.xml.PetDataTable; @@ -82,15 +82,12 @@ public class PetFood implements IItemHandler final Player player = activeChar.getActingPlayer(); if (player.isMounted()) { - final List foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); - if (foodIds.contains(item.getId())) + final Set foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); + if (foodIds.contains(item.getId()) && player.destroyItem("Consume", item.getObjectId(), 1, null, false)) { - if (player.destroyItem("Consume", item.getObjectId(), 1, null, false)) - { - player.broadcastPacket(new MagicSkillUse(player, player, skillId, skillLevel, 0, 0)); - player.setCurrentFeed(player.getCurrentFeed() + skill.getFeed()); - return true; - } + player.broadcastPacket(new MagicSkillUse(player, player, skillId, skillLevel, 0, 0)); + player.setCurrentFeed(player.getCurrentFeed() + skill.getFeed()); + return true; } } final SystemMessage sm = new SystemMessage(SystemMessageId.S1_CANNOT_BE_USED_DUE_TO_UNSUITABLE_TERMS); diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java index ba6c584e35..50fa3a822d 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java @@ -277,7 +277,7 @@ public class Config public static boolean AUTO_LOOT_SLOT_LIMIT; public static int LOOT_RAIDS_PRIVILEGE_INTERVAL; public static int LOOT_RAIDS_PRIVILEGE_CC_SIZE; - public static List AUTO_LOOT_ITEM_IDS; + public static Set AUTO_LOOT_ITEM_IDS; public static boolean ENABLE_KEYBOARD_MOVEMENT; public static int UNSTUCK_INTERVAL; public static int TELEPORT_WATCHDOG_TIMEOUT; @@ -521,7 +521,7 @@ public class Config public static boolean ALLOW_DISCARDITEM; public static int AUTODESTROY_ITEM_AFTER; public static int HERB_AUTO_DESTROY_TIME; - public static List LIST_PROTECTED_ITEMS; + public static Set LIST_PROTECTED_ITEMS; public static boolean DATABASE_CLEAN_UP; public static int CHAR_DATA_STORE_INTERVAL; public static boolean LAZY_ITEMS_UPDATE; @@ -617,7 +617,7 @@ public class Config public static boolean ALT_OLY_LOG_FIGHTS; public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS; public static boolean ALT_OLY_ANNOUNCE_GAMES; - public static List LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(); + public static Set LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(); public static int ALT_OLY_ENCHANT_LIMIT; public static int ALT_OLY_WAIT_TIME; public static boolean ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS; @@ -1232,9 +1232,9 @@ public class Config public static int AUTO_CP_PERCENTAGE; public static int AUTO_HP_PERCENTAGE; public static int AUTO_MP_PERCENTAGE; - public static List AUTO_CP_ITEM_IDS; - public static List AUTO_HP_ITEM_IDS; - public static List AUTO_MP_ITEM_IDS; + public static Set AUTO_CP_ITEM_IDS; + public static Set AUTO_HP_ITEM_IDS; + public static Set AUTO_MP_ITEM_IDS; public static boolean CUSTOM_STARTING_LOC; public static int CUSTOM_STARTING_LOC_X; public static int CUSTOM_STARTING_LOC_Y; @@ -1244,7 +1244,7 @@ public class Config public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; public static int MOB_MIN_SPAWN_RANGE; public static int MOB_MAX_SPAWN_RANGE; - public static List MOBS_LIST_NOT_RANDOM; + public static Set MOBS_LIST_NOT_RANDOM; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; public static boolean COMMUNITYBOARD_ENABLE_MULTISELLS; @@ -1262,7 +1262,7 @@ public class Config public static boolean COMMUNITY_PREMIUM_SYSTEM_ENABLED; public static int COMMUNITY_PREMIUM_COIN_ID; public static int COMMUNITY_PREMIUM_PRICE_PER_DAY; - public static List COMMUNITY_AVAILABLE_BUFFS; + public static Set COMMUNITY_AVAILABLE_BUFFS; public static Map COMMUNITY_AVAILABLE_TELEPORTS; public static boolean CUSTOM_MAIL_MANAGER_ENABLED; public static int CUSTOM_MAIL_MANAGER_DELAY; @@ -1934,7 +1934,7 @@ public class Config LOOT_RAIDS_PRIVILEGE_INTERVAL = characterConfig.getInt("RaidLootRightsInterval", 900) * 1000; LOOT_RAIDS_PRIVILEGE_CC_SIZE = characterConfig.getInt("RaidLootRightsCCSize", 45); final String[] autoLootItemIds = characterConfig.getString("AutoLootItemIds", "0").split(","); - AUTO_LOOT_ITEM_IDS = new ArrayList<>(autoLootItemIds.length); + AUTO_LOOT_ITEM_IDS = new HashSet<>(autoLootItemIds.length); for (String item : autoLootItemIds) { Integer itm = 0; @@ -2049,7 +2049,7 @@ public class Config AUTODESTROY_ITEM_AFTER = generalConfig.getInt("AutoDestroyDroppedItemAfter", 600); HERB_AUTO_DESTROY_TIME = generalConfig.getInt("AutoDestroyHerbTime", 60) * 1000; final String[] split = generalConfig.getString("ListOfProtectedItems", "0").split(","); - LIST_PROTECTED_ITEMS = new ArrayList<>(split.length); + LIST_PROTECTED_ITEMS = new HashSet<>(split.length); for (String id : split) { LIST_PROTECTED_ITEMS.add(Integer.parseInt(id)); @@ -2490,7 +2490,7 @@ public class Config if (!olyRestrictedItems.isEmpty()) { final String[] olyRestrictedItemsSplit = olyRestrictedItems.split(","); - LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(olyRestrictedItemsSplit.length); + LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(olyRestrictedItemsSplit.length); for (String id : olyRestrictedItemsSplit) { LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id)); @@ -2632,17 +2632,17 @@ public class Config AUTO_CP_PERCENTAGE = autoPotionsConfig.getInt("AutoCpPercentage", 70); AUTO_HP_PERCENTAGE = autoPotionsConfig.getInt("AutoHpPercentage", 70); AUTO_MP_PERCENTAGE = autoPotionsConfig.getInt("AutoMpPercentage", 70); - AUTO_CP_ITEM_IDS = new ArrayList<>(); + AUTO_CP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoCpItemIds", "0").split(",")) { AUTO_CP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_HP_ITEM_IDS = new ArrayList<>(); + AUTO_HP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoHpItemIds", "0").split(",")) { AUTO_HP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_MP_ITEM_IDS = new ArrayList<>(); + AUTO_MP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoMpItemIds", "0").split(",")) { AUTO_MP_ITEM_IDS.add(Integer.parseInt(s)); @@ -2746,7 +2746,7 @@ public class Config COMMUNITY_PREMIUM_COIN_ID = communityBoardConfig.getInt("CommunityPremiumBuyCoinId", 57); COMMUNITY_PREMIUM_PRICE_PER_DAY = communityBoardConfig.getInt("CommunityPremiumPricePerDay", 1000000); final String[] allowedBuffs = communityBoardConfig.getString("CommunityAvailableBuffs", "").split(","); - COMMUNITY_AVAILABLE_BUFFS = new ArrayList<>(allowedBuffs.length); + COMMUNITY_AVAILABLE_BUFFS = new HashSet<>(allowedBuffs.length); for (String s : allowedBuffs) { COMMUNITY_AVAILABLE_BUFFS.add(Integer.parseInt(s)); @@ -3015,7 +3015,7 @@ public class Config if (ENABLE_RANDOM_MONSTER_SPAWNS) { final String[] mobsIds = randomSpawnsConfig.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); - MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + MOBS_LIST_NOT_RANDOM = new HashSet<>(mobsIds.length); for (String id : mobsIds) { MOBS_LIST_NOT_RANDOM.add(Integer.parseInt(id)); diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java index 6aa0a1fdde..fb395b9e2d 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java @@ -17,10 +17,10 @@ package org.l2jmobius.gameserver.data.xml; import java.io.File; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -42,7 +42,7 @@ public class FakePlayerData implements IXmlReader private final Map _fakePlayerInfos = new HashMap<>(); private final Map _fakePlayerNames = new HashMap<>(); private final Map _fakePlayerIds = new HashMap<>(); - private final List _talkableFakePlayerNames = new ArrayList<>(); + private final Set _talkableFakePlayerNames = new HashSet<>(); protected FakePlayerData() { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/data/xml/SkillTreeData.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/data/xml/SkillTreeData.java index 91aeb0879a..c92b0f5726 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/data/xml/SkillTreeData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/data/xml/SkillTreeData.java @@ -41,8 +41,8 @@ import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.enums.SocialClass; import org.l2jmobius.gameserver.model.SkillLearn; import org.l2jmobius.gameserver.model.SkillLearn.SubClassData; -import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.model.clan.Clan; import org.l2jmobius.gameserver.model.holders.ItemHolder; import org.l2jmobius.gameserver.model.holders.PlayerSkillHolder; diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java index 644492e781..7326f470c7 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java @@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -49,7 +51,7 @@ import org.l2jmobius.gameserver.util.Util; public class SellBuffsManager implements IXmlReader { private static final Logger LOGGER = Logger.getLogger(SellBuffsManager.class.getName()); - private static final List ALLOWED_BUFFS = new ArrayList<>(); + private static final Set ALLOWED_BUFFS = new HashSet<>(); private static final String HTML_FOLDER = "data/html/mods/SellBuffs/"; protected SellBuffsManager() @@ -76,11 +78,7 @@ public class SellBuffsManager implements IXmlReader { final Element elem = (Element) node.item(i); final int skillId = Integer.parseInt(elem.getAttribute("id")); - - if (!ALLOWED_BUFFS.contains(skillId)) - { - ALLOWED_BUFFS.add(skillId); - } + ALLOWED_BUFFS.add(skillId); } } diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java index b10f75ef3d..1e45a21319 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java @@ -19,8 +19,10 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; @@ -67,7 +69,7 @@ public class WalkingManager implements IXmlReader public static final byte REPEAT_TELE_FIRST = 2; public static final byte REPEAT_RANDOM = 3; - private final List _targetedNpcIds = new ArrayList<>(); + private final Set _targetedNpcIds = new HashSet<>(); private final Map _routes = new HashMap<>(); // all available routes private final Map _activeRoutes = new HashMap<>(); // each record represents NPC, moving by predefined route from _routes, and moving progress private final Map _routesToAttach = new HashMap<>(); // each record represents NPC and all available routes for it diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/BlockList.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/BlockList.java index 886a920fff..e484567678 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/BlockList.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/BlockList.java @@ -19,9 +19,9 @@ package org.l2jmobius.gameserver.model; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -35,10 +35,11 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; public class BlockList { private static final Logger LOGGER = Logger.getLogger(BlockList.class.getName()); - private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); + + private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); private final Player _owner; - private List _blockList; + private Set _blockList; public BlockList(Player owner) { @@ -67,9 +68,9 @@ public class BlockList OFFLINE_LIST.put(_owner.getObjectId(), _blockList); } - private static List loadList(int objId) + private static Set loadList(int objId) { - final List list = new ArrayList<>(); + final Set list = new HashSet<>(); try (Connection con = DatabaseFactory.getConnection(); PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1")) { @@ -157,7 +158,7 @@ public class BlockList _owner.setMessageRefusal(value); } - private List getBlockList() + private Set getBlockList() { return _blockList; } diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/PetData.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/PetData.java index 877b1b7703..b2a937de45 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/PetData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/PetData.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; import org.l2jmobius.gameserver.model.holders.SkillHolder; @@ -39,7 +41,7 @@ public class PetData private int _hungryLimit = 1; private int _minLevel = Byte.MAX_VALUE; private boolean _syncLevel = false; - private final List _food = new ArrayList<>(); + private final Set _food = new HashSet<>(); public PetData(int npcId, int itemId) { @@ -120,7 +122,7 @@ public class PetData /** * @return the pet's food list. */ - public List getFood() + public Set getFood() { return _food; } diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/SkillLearn.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/SkillLearn.java index 4b03bcf359..3949ef0eab 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/SkillLearn.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/SkillLearn.java @@ -17,7 +17,10 @@ package org.l2jmobius.gameserver.model; import java.util.ArrayList; +import java.util.EnumSet; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.Config; import org.l2jmobius.gameserver.enums.ClassId; @@ -37,13 +40,13 @@ public class SkillLearn private final int _getLevel; private final boolean _autoGet; private final int _levelUpSp; - private final List _requiredItems = new ArrayList<>(); - private final List _races = new ArrayList<>(); - private final List _preReqSkills = new ArrayList<>(); + private final Set _requiredItems = new HashSet<>(1); + private final Set _races = EnumSet.noneOf(Race.class); + private final Set _preReqSkills = new HashSet<>(1); private SocialClass _socialClass; private final boolean _residenceSkill; - private final List _residenceIds = new ArrayList<>(); - private final List _subClassLvlNumber = new ArrayList<>(); + private final Set _residenceIds = new HashSet<>(1); + private final List _subClassLvlNumber = new ArrayList<>(1); private final boolean _learnedByNpc; private final boolean _learnedByFS; @@ -141,9 +144,9 @@ public class SkillLearn } /** - * @return the list with the item holders required to acquire this skill. + * @return the set with the item holders required to acquire this skill. */ - public List getRequiredItems() + public Set getRequiredItems() { return _requiredItems; } @@ -158,9 +161,9 @@ public class SkillLearn } /** - * @return a list with the races that can acquire this skill. + * @return a set with the races that can acquire this skill. */ - public List getRaces() + public Set getRaces() { return _races; } @@ -175,9 +178,9 @@ public class SkillLearn } /** - * @return the list of skill holders required to acquire this skill. + * @return the set of skill holders required to acquire this skill. */ - public List getPreReqSkills() + public Set getPreReqSkills() { return _preReqSkills; } @@ -220,9 +223,9 @@ public class SkillLearn } /** - * @return a list with the Ids where this skill is available. + * @return a set with the Ids where this skill is available. */ - public List getResidenceIds() + public Set getResidenceIds() { return _residenceIds; } diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java index 13bffc0c4e..4dba093df8 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java @@ -21,6 +21,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.LinkedList; import java.util.List; +import java.util.Set; import java.util.concurrent.Future; import java.util.logging.Level; import java.util.logging.Logger; @@ -172,7 +173,7 @@ public class Pet extends Summon setCurrentFed(_curFed > getFeedConsume() ? _curFed - getFeedConsume() : 0); broadcastStatusUpdate(); - final List foodIds = getPetData().getFood(); + final Set foodIds = getPetData().getFood(); if (foodIds.isEmpty()) { if (isUncontrollable()) diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java index f00cc1d74f..9129130a9b 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java @@ -16,8 +16,8 @@ */ package org.l2jmobius.gameserver.model.actor.instance; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import org.l2jmobius.commons.threads.ThreadPool; @@ -57,7 +57,7 @@ public class Trap extends Npc private boolean _isTriggered; private final int _lifeTime; private Player _owner; - private final List _playersWhoDetectedMe = new ArrayList<>(); + private final Set _playersWhoDetectedMe = new HashSet<>(); private final SkillHolder _skill; private int _remainingTime; // Tasks diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java index 52626d9b27..a819aaa917 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor.tasks.player; -import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -69,7 +69,7 @@ public class PetFeedTask implements Runnable return; } - final List foodIds = PetDataTable.getInstance().getPetData(_player.getMountNpcId()).getFood(); + final Set foodIds = PetDataTable.getInstance().getPetData(_player.getMountNpcId()).getFood(); if (foodIds.isEmpty()) { return; diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java index 50d2a821c3..2611b5f121 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.actor.Creature; @@ -29,9 +29,9 @@ import org.l2jmobius.gameserver.model.zone.ZoneType; */ public class ConditionPlayerInsideZoneId extends Condition { - private final List _zones; + private final Set _zones; - public ConditionPlayerInsideZoneId(List zones) + public ConditionPlayerInsideZoneId(Set zones) { _zones = zones; } diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java index 40ac9d5ebd..b9db8f8c40 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.instancemanager.InstanceManager; import org.l2jmobius.gameserver.model.actor.Creature; @@ -29,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerInstanceId extends Condition { - private final List _instanceIds; + private final Set _instanceIds; /** * Instantiates a new condition player instance id. * @param instanceIds the instance ids */ - public ConditionPlayerInstanceId(List instanceIds) + public ConditionPlayerInstanceId(Set instanceIds) { _instanceIds = instanceIds; } diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java index 0fbb77301a..7c375ec45e 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -28,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerRace extends Condition { - private final Race[] _races; + private final Set _races; /** * Instantiates a new condition player race. * @param races the list containing the allowed races. */ - public ConditionPlayerRace(Race[] races) + public ConditionPlayerRace(Set races) { _races = races; } @@ -42,6 +43,10 @@ public class ConditionPlayerRace extends Condition @Override public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { - return (effector != null) && effector.isPlayer() && CommonUtil.contains(_races, effector.getActingPlayer().getRace()); + if ((effector == null) || !effector.isPlayer()) + { + return false; + } + return _races.contains(effector.getActingPlayer().getRace()); } } diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java index 0f54766571..0b326e3f40 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId())) + if (_npcIds.contains(target.getId())) { existNpc = true; break; diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java index 161164ed30..78c281e88a 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetClassIdRestriction extends Condition { - private final List _classIds; + private final Set _classIds; /** * Instantiates a new condition target class id restriction. * @param classId the class id */ - public ConditionTargetClassIdRestriction(List classId) + public ConditionTargetClassIdRestriction(Set classId) { _classIds = classId; } diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java index 7de1f3b20a..c723f58d10 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; @@ -28,13 +28,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetNpcId extends Condition { - private final List _npcIds; + private final Set _npcIds; /** * Instantiates a new condition target npc id. * @param npcIds the npc ids */ - public ConditionTargetNpcId(List npcIds) + public ConditionTargetNpcId(Set npcIds) { _npcIds = npcIds; } diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java index f26329bc21..5c86f26ae5 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.holders; -import java.util.Collection; +import java.util.Set; /** * @author Mobius @@ -25,9 +25,9 @@ public class EventDropHolder extends DropHolder { private final int _minLevel; private final int _maxLevel; - private final Collection _monsterIds; + private final Set _monsterIds; - public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Collection monsterIds) + public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Set monsterIds) { super(null, itemId, min, max, chance); _minLevel = minLevel; @@ -45,7 +45,7 @@ public class EventDropHolder extends DropHolder return _maxLevel; } - public Collection getMonsterIds() + public Set getMonsterIds() { return _monsterIds; } diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/item/Henna.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/item/Henna.java index 65a4b9fb37..de64df91e0 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/item/Henna.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/item/Henna.java @@ -16,8 +16,9 @@ */ package org.l2jmobius.gameserver.model.item; -import java.util.ArrayList; +import java.util.EnumSet; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.enums.ClassId; import org.l2jmobius.gameserver.model.StatSet; @@ -40,7 +41,7 @@ public class Henna private final int _wearCount; private final int _cancelFee; private final int _cancelCount; - private final List _wearClass; + private final Set _wearClass; public Henna(StatSet set) { @@ -56,7 +57,7 @@ public class Henna _wearCount = set.getInt("wear_count"); _cancelFee = set.getInt("cancel_fee"); _cancelCount = set.getInt("cancel_count"); - _wearClass = new ArrayList<>(); + _wearClass = EnumSet.noneOf(ClassId.class); } /** @@ -158,7 +159,7 @@ public class Henna /** * @return the list with the allowed classes to wear this dye. */ - public List getAllowedWearClass() + public Set getAllowedWearClass() { return _wearClass; } diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java index f9c744cc8e..38ebbfbd3a 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java @@ -16,16 +16,16 @@ */ package org.l2jmobius.gameserver.model.item.enchant; +import java.util.EnumSet; +import java.util.Set; import java.util.logging.Logger; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.item.ItemTemplate; import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.model.item.type.CrystalType; import org.l2jmobius.gameserver.model.item.type.EtcItemType; -import org.l2jmobius.gameserver.model.item.type.ItemType; /** * @author UnAfraid @@ -34,17 +34,18 @@ public abstract class AbstractEnchantItem { protected static final Logger LOGGER = Logger.getLogger(AbstractEnchantItem.class.getName()); - private static final ItemType[] ENCHANT_TYPES = new ItemType[] + private static final Set ENCHANT_TYPES = EnumSet.noneOf(EtcItemType.class); + static { - EtcItemType.ANCIENT_CRYSTAL_ENCHANT_AM, - EtcItemType.ANCIENT_CRYSTAL_ENCHANT_WP, - EtcItemType.BLESS_SCRL_ENCHANT_AM, - EtcItemType.BLESS_SCRL_ENCHANT_WP, - EtcItemType.SCRL_ENCHANT_AM, - EtcItemType.SCRL_ENCHANT_WP, - EtcItemType.SCRL_INC_ENCHANT_PROP_AM, - EtcItemType.SCRL_INC_ENCHANT_PROP_WP, - }; + ENCHANT_TYPES.add(EtcItemType.ANCIENT_CRYSTAL_ENCHANT_AM); + ENCHANT_TYPES.add(EtcItemType.ANCIENT_CRYSTAL_ENCHANT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESS_SCRL_ENCHANT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESS_SCRL_ENCHANT_WP); + ENCHANT_TYPES.add(EtcItemType.SCRL_ENCHANT_AM); + ENCHANT_TYPES.add(EtcItemType.SCRL_ENCHANT_WP); + ENCHANT_TYPES.add(EtcItemType.SCRL_INC_ENCHANT_PROP_AM); + ENCHANT_TYPES.add(EtcItemType.SCRL_INC_ENCHANT_PROP_WP); + } private final int _id; private final CrystalType _grade; @@ -58,7 +59,7 @@ public abstract class AbstractEnchantItem { throw new NullPointerException(); } - else if (!CommonUtil.contains(ENCHANT_TYPES, getItem().getItemType())) + else if (!ENCHANT_TYPES.contains(getItem().getItemType())) { throw new IllegalAccessError(); } @@ -146,7 +147,7 @@ public abstract class AbstractEnchantItem * @param type2 * @return {@code true} if current type2 is valid to be enchanted, {@code false} otherwise */ - private final boolean isValidItemType(int type2) + private boolean isValidItemType(int type2) { if (type2 == ItemTemplate.TYPE2_WEAPON) { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java index 418d641a31..bba81ea0be 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java @@ -24,8 +24,10 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Set; import java.util.logging.Level; import javax.xml.parsers.DocumentBuilder; @@ -175,7 +177,7 @@ public class LongTimeEvent extends Quest final Node maxLevelNode = d.getAttributes().getNamedItem("maxLevel"); final int maxLevel = maxLevelNode == null ? Integer.MAX_VALUE : Integer.parseInt(maxLevelNode.getNodeValue()); final Node monsterIdsNode = d.getAttributes().getNamedItem("monsterIds"); - final List monsterIds = new ArrayList<>(); + final Set monsterIds = new HashSet<>(); if (monsterIdsNode != null) { for (String id : monsterIdsNode.getNodeValue().split(",")) diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/siege/Castle.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/siege/Castle.java index aeffed81cb..cc4d62eb7a 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/siege/Castle.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/siege/Castle.java @@ -21,8 +21,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.Calendar; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -78,8 +80,8 @@ public class Castle extends AbstractResidence private SiegeZone _zone = null; private ResidenceTeleportZone _teleZone; private Clan _formerOwner = null; - private final List _artefacts = new ArrayList<>(1); - private final Map _function; + private final Set _artefacts = new HashSet<>(1); + private final Map _function = new ConcurrentHashMap<>(); private int _ticketBuyCount = 0; private boolean _isFirstMidVictory = false; @@ -237,10 +239,6 @@ public class Castle extends AbstractResidence { super(castleId); load(); - /* - * if (getResidenceId() == 7 || castleId == 9) // Goddard and Schuttgart _nbArtifact = 2; - */ - _function = new ConcurrentHashMap<>(); initResidenceZone(); if (_ownerId != 0) { @@ -1075,7 +1073,7 @@ public class Castle extends AbstractResidence _artefacts.add(artefact); } - public List getArtefacts() + public Set getArtefacts() { return _artefacts; } diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/util/DocumentBase.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/util/DocumentBase.java index cb42fd94ff..e48286b1ba 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/util/DocumentBase.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/util/DocumentBase.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.util; import java.io.File; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -476,12 +477,12 @@ public abstract class DocumentBase case "races": { final String[] racesVal = a.getNodeValue().split(","); - final Race[] races = new Race[racesVal.length]; + final Set races = EnumSet.noneOf(Race.class); for (int r = 0; r < racesVal.length; r++) { if (racesVal[r] != null) { - races[r] = Race.valueOf(racesVal[r]); + races.add(Race.valueOf(racesVal[r])); } } cond = joinAnd(cond, new ConditionPlayerRace(races)); @@ -752,13 +753,13 @@ public abstract class DocumentBase case "instanceid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionPlayerInstanceId(array)); + cond = joinAnd(cond, new ConditionPlayerInstanceId(set)); break; } case "agathionid": @@ -803,10 +804,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -882,13 +883,13 @@ public abstract class DocumentBase case "insidezoneid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionPlayerInsideZoneId(array)); + cond = joinAnd(cond, new ConditionPlayerInsideZoneId(set)); break; } case "checkabnormal": @@ -978,13 +979,13 @@ public abstract class DocumentBase case "class_id_restriction": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetClassIdRestriction(array)); + cond = joinAnd(cond, new ConditionTargetClassIdRestriction(set)); break; } case "active_effect_id": @@ -1062,13 +1063,13 @@ public abstract class DocumentBase case "npcid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetNpcId(array)); + cond = joinAnd(cond, new ConditionTargetNpcId(set)); break; } case "npctype": diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/bypasshandlers/Link.java b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/bypasshandlers/Link.java index 380a9f1ae3..93bc7f3647 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/bypasshandlers/Link.java +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/bypasshandlers/Link.java @@ -16,7 +16,9 @@ */ package handlers.bypasshandlers; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.HashSet; +import java.util.Set; + import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.handler.IBypassHandler; import org.l2jmobius.gameserver.model.actor.Creature; @@ -31,37 +33,38 @@ public class Link implements IBypassHandler "Link" }; - private static final String[] VALID_LINKS = + private static final Set VALID_LINKS = new HashSet<>(); + static { - "common/craft_01.htm", - "common/craft_02.htm", - "common/runes_01.htm", - "common/sealed_runes_01.htm", - "common/sealed_runes_02.htm", - "common/sealed_runes_03.htm", - "common/sealed_runes_04.htm", - "common/sealed_runes_05.htm", - "common/sealed_runes_06.htm", - "common/sealed_runes_07.htm", - "common/sealed_runes_08.htm", - "common/sealed_runes_09.htm", - "common/skill_enchant_help_01.htm", - "common/skill_enchant_help_02.htm", - "common/skill_enchant_help_03.htm", - "default/BlessingOfProtection.htm", - "default/SupportMagic.htm", - "fisherman/fishing_manual001.htm", - "fisherman/fishing_manual002.htm", - "fisherman/fishing_manual003.htm", - "fisherman/fishing_manual004.htm", - "fisherman/fishing_manual005.htm", - "fortress/foreman.htm", - "petmanager/evolve.htm", - "petmanager/exchange.htm", - "petmanager/instructions.htm", - "warehouse/clanwh.htm", - "warehouse/privatewh.htm", - }; + VALID_LINKS.add("common/craft_01.htm"); + VALID_LINKS.add("common/craft_02.htm"); + VALID_LINKS.add("common/runes_01.htm"); + VALID_LINKS.add("common/runes_01.htm"); + VALID_LINKS.add("common/sealed_runes_02.htm"); + VALID_LINKS.add("common/sealed_runes_03.htm"); + VALID_LINKS.add("common/sealed_runes_04.htm"); + VALID_LINKS.add("common/sealed_runes_05.htm"); + VALID_LINKS.add("common/sealed_runes_06.htm"); + VALID_LINKS.add("common/sealed_runes_07.htm"); + VALID_LINKS.add("common/sealed_runes_08.htm"); + VALID_LINKS.add("common/sealed_runes_09.htm"); + VALID_LINKS.add("common/skill_enchant_help_01.htm"); + VALID_LINKS.add("common/skill_enchant_help_02.htm"); + VALID_LINKS.add("common/skill_enchant_help_03.htm"); + VALID_LINKS.add("default/BlessingOfProtection.htm"); + VALID_LINKS.add("default/SupportMagic.htm"); + VALID_LINKS.add("fisherman/fishing_manual001.htm"); + VALID_LINKS.add("fisherman/fishing_manual002.htm"); + VALID_LINKS.add("fisherman/fishing_manual003.htm"); + VALID_LINKS.add("fisherman/fishing_manual004.htm"); + VALID_LINKS.add("fisherman/fishing_manual008.htm"); + VALID_LINKS.add("fortress/foreman.htm"); + VALID_LINKS.add("petmanager/evolve.htm"); + VALID_LINKS.add("petmanager/exchange.htm"); + VALID_LINKS.add("petmanager/instructions.htm"); + VALID_LINKS.add("warehouse/clanwh.htm"); + VALID_LINKS.add("warehouse/privatewh.htm"); + } @Override public boolean useBypass(String command, Player player, Creature target) @@ -79,12 +82,13 @@ public class Link implements IBypassHandler return false; } - String content = CommonUtil.contains(VALID_LINKS, htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; + String content = VALID_LINKS.contains(htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; // Precaution. if (htmlPath.startsWith("teleporter/") && !(player.getTarget() instanceof Teleporter)) { content = null; } + final NpcHtmlMessage html = new NpcHtmlMessage(target != null ? target.getObjectId() : 0); if (content != null) { diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/itemhandlers/PetFood.java b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/itemhandlers/PetFood.java index 3c5572d4ec..8b908ea095 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/itemhandlers/PetFood.java +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/itemhandlers/PetFood.java @@ -17,6 +17,7 @@ package handlers.itemhandlers; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.PetDataTable; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -79,7 +80,7 @@ public class PetFood implements IItemHandler final Player player = activeChar.getActingPlayer(); if (player.isMounted()) { - final List foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); + final Set foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); if (foodIds.contains(item.getId()) && player.destroyItem("Consume", item.getObjectId(), 1, null, false)) { player.broadcastPacket(new MagicSkillUse(player, player, skillId, skillLevel, 0, 0)); diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java index 2ad282f683..99f45fbb41 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.ClanHallData; import org.l2jmobius.gameserver.model.StatSet; @@ -32,12 +33,12 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpCheckResidenceSkillCondition implements ISkillCondition { - private final List _residencesId; + private final Set _residencesId = new HashSet<>(); private final boolean _isWithin; public OpCheckResidenceSkillCondition(StatSet params) { - _residencesId = params.getList("residencesId", Integer.class); + _residencesId.addAll(params.getList("residencesId", Integer.class)); _isWithin = params.getBoolean("isWithin"); } diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java index fc2934423b..4a8282d988 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java @@ -16,9 +16,9 @@ */ package handlers.skillconditionhandlers; -import java.util.ArrayList; -import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -28,18 +28,18 @@ import org.l2jmobius.gameserver.model.skill.ISkillCondition; import org.l2jmobius.gameserver.model.skill.Skill; /** - * @author UnAfraid + * @author UnAfraid, Mobius */ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition { - private final List _npcIds = new ArrayList<>(); + private final Set _npcIds = new HashSet<>(); public OpNeedSummonOrPetSkillCondition(StatSet params) { - final List npcIds = params.getList("npcIds", String.class); + final List npcIds = params.getList("npcIds", Integer.class); if (npcIds != null) { - npcIds.stream().map(Integer::valueOf).forEach(_npcIds::add); + _npcIds.addAll(npcIds); } } @@ -47,7 +47,19 @@ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition public boolean canUse(Creature caster, Skill skill, WorldObject target) { final Summon pet = caster.getPet(); - final Collection summons = caster.getServitors().values(); - return ((pet != null) && _npcIds.stream().anyMatch(npcId -> npcId == pet.getId())) || summons.stream().anyMatch(summon -> _npcIds.contains(summon.getId())); + if ((pet != null) && _npcIds.contains(pet.getId())) + { + return true; + } + + for (Summon summon : caster.getServitors().values()) + { + if (_npcIds.contains(summon.getId())) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java index 8541bc62b4..ef81b291d4 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,11 +30,11 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetDoorSkillCondition implements ISkillCondition { - private final List _doorIds; + private final Set _doorIds = new HashSet<>(); public OpTargetDoorSkillCondition(StatSet params) { - _doorIds = params.getList("doorIds", Integer.class); + _doorIds.addAll(params.getList("doorIds", Integer.class)); } @Override diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java index 3ce4145703..0ccd571e19 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,17 +30,17 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetNpcSkillCondition implements ISkillCondition { - private final List _npcId; + private final Set _npcIds = new HashSet<>(); public OpTargetNpcSkillCondition(StatSet params) { - _npcId = params.getList("npcIds", Integer.class); + _npcIds.addAll(params.getList("npcIds", Integer.class)); } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget(); - return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId()); + return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcIds.contains(actualTarget.getId()); } } diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/instances/AbstractInstance.java b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/instances/AbstractInstance.java index 94c337f0df..a5b4ef238a 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/instances/AbstractInstance.java +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/instances/AbstractInstance.java @@ -16,9 +16,10 @@ */ package instances; +import java.util.HashSet; import java.util.List; +import java.util.Set; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.enums.InstanceReenterType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.instancemanager.InstanceManager; @@ -40,25 +41,29 @@ import ai.AbstractNpcAI; */ public abstract class AbstractInstance extends AbstractNpcAI { - private final int[] _templateIds; + private final Set _templateIds = new HashSet<>(); - public AbstractInstance(int... templateId) + public AbstractInstance(int... templateIds) { - if (templateId.length == 0) + if (templateIds.length == 0) { throw new IllegalStateException("No template ids were provided!"); } - _templateIds = templateId; + + for (int templateId : templateIds) + { + _templateIds.add(templateId); + } } - public int[] getTemplateId() + public Set getTemplateId() { return _templateIds; } public boolean isInInstance(Instance instance) { - return (instance != null) && CommonUtil.contains(_templateIds, instance.getTemplateId()); + return (instance != null) && _templateIds.contains(instance.getTemplateId()); } /** diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/Config.java index 131622fe2a..e03eb8835f 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/Config.java @@ -286,7 +286,7 @@ public class Config public static boolean AUTO_LOOT_SLOT_LIMIT; public static int LOOT_RAIDS_PRIVILEGE_INTERVAL; public static int LOOT_RAIDS_PRIVILEGE_CC_SIZE; - public static List AUTO_LOOT_ITEM_IDS; + public static Set AUTO_LOOT_ITEM_IDS; public static boolean ENABLE_KEYBOARD_MOVEMENT; public static int UNSTUCK_INTERVAL; public static int TELEPORT_WATCHDOG_TIMEOUT; @@ -476,7 +476,7 @@ public class Config public static boolean ALLOW_DISCARDITEM; public static int AUTODESTROY_ITEM_AFTER; public static int HERB_AUTO_DESTROY_TIME; - public static List LIST_PROTECTED_ITEMS; + public static Set LIST_PROTECTED_ITEMS; public static boolean DATABASE_CLEAN_UP; public static int CHAR_DATA_STORE_INTERVAL; public static int CLAN_VARIABLES_STORE_INTERVAL; @@ -567,7 +567,7 @@ public class Config public static boolean ALT_OLY_LOG_FIGHTS; public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS; public static boolean ALT_OLY_ANNOUNCE_GAMES; - public static List LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(); + public static Set LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(); public static int ALT_OLY_WEAPON_ENCHANT_LIMIT; public static int ALT_OLY_ARMOR_ENCHANT_LIMIT; public static int ALT_OLY_WAIT_TIME; @@ -1156,9 +1156,9 @@ public class Config public static int AUTO_CP_PERCENTAGE; public static int AUTO_HP_PERCENTAGE; public static int AUTO_MP_PERCENTAGE; - public static List AUTO_CP_ITEM_IDS; - public static List AUTO_HP_ITEM_IDS; - public static List AUTO_MP_ITEM_IDS; + public static Set AUTO_CP_ITEM_IDS; + public static Set AUTO_HP_ITEM_IDS; + public static Set AUTO_MP_ITEM_IDS; public static boolean CUSTOM_STARTING_LOC; public static int CUSTOM_STARTING_LOC_X; public static int CUSTOM_STARTING_LOC_Y; @@ -1168,7 +1168,7 @@ public class Config public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; public static int MOB_MIN_SPAWN_RANGE; public static int MOB_MAX_SPAWN_RANGE; - public static List MOBS_LIST_NOT_RANDOM; + public static Set MOBS_LIST_NOT_RANDOM; public static boolean FREE_JUMPS_FOR_ALL; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; @@ -1187,7 +1187,7 @@ public class Config public static boolean COMMUNITY_PREMIUM_SYSTEM_ENABLED; public static int COMMUNITY_PREMIUM_COIN_ID; public static int COMMUNITY_PREMIUM_PRICE_PER_DAY; - public static List COMMUNITY_AVAILABLE_BUFFS; + public static Set COMMUNITY_AVAILABLE_BUFFS; public static Map COMMUNITY_AVAILABLE_TELEPORTS; public static boolean CUSTOM_DEPOSITABLE_ENABLED; public static boolean CUSTOM_DEPOSITABLE_QUEST_ITEMS; @@ -1835,7 +1835,7 @@ public class Config LOOT_RAIDS_PRIVILEGE_INTERVAL = characterConfig.getInt("RaidLootRightsInterval", 900) * 1000; LOOT_RAIDS_PRIVILEGE_CC_SIZE = characterConfig.getInt("RaidLootRightsCCSize", 45); final String[] autoLootItemIds = characterConfig.getString("AutoLootItemIds", "0").split(","); - AUTO_LOOT_ITEM_IDS = new ArrayList<>(autoLootItemIds.length); + AUTO_LOOT_ITEM_IDS = new HashSet<>(autoLootItemIds.length); for (String item : autoLootItemIds) { Integer itm = 0; @@ -1955,7 +1955,7 @@ public class Config AUTODESTROY_ITEM_AFTER = generalConfig.getInt("AutoDestroyDroppedItemAfter", 600); HERB_AUTO_DESTROY_TIME = generalConfig.getInt("AutoDestroyHerbTime", 60) * 1000; final String[] split = generalConfig.getString("ListOfProtectedItems", "0").split(","); - LIST_PROTECTED_ITEMS = new ArrayList<>(split.length); + LIST_PROTECTED_ITEMS = new HashSet<>(split.length); for (String id : split) { LIST_PROTECTED_ITEMS.add(Integer.parseInt(id)); @@ -2349,7 +2349,7 @@ public class Config if (!olyRestrictedItems.isEmpty()) { final String[] olyRestrictedItemsSplit = olyRestrictedItems.split(","); - LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(olyRestrictedItemsSplit.length); + LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(olyRestrictedItemsSplit.length); for (String id : olyRestrictedItemsSplit) { LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id)); @@ -2461,17 +2461,17 @@ public class Config AUTO_CP_PERCENTAGE = autoPotionsConfig.getInt("AutoCpPercentage", 70); AUTO_HP_PERCENTAGE = autoPotionsConfig.getInt("AutoHpPercentage", 70); AUTO_MP_PERCENTAGE = autoPotionsConfig.getInt("AutoMpPercentage", 70); - AUTO_CP_ITEM_IDS = new ArrayList<>(); + AUTO_CP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoCpItemIds", "0").split(",")) { AUTO_CP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_HP_ITEM_IDS = new ArrayList<>(); + AUTO_HP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoHpItemIds", "0").split(",")) { AUTO_HP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_MP_ITEM_IDS = new ArrayList<>(); + AUTO_MP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoMpItemIds", "0").split(",")) { AUTO_MP_ITEM_IDS.add(Integer.parseInt(s)); @@ -3081,7 +3081,7 @@ public class Config COMMUNITY_PREMIUM_COIN_ID = communityBoardConfig.getInt("CommunityPremiumBuyCoinId", 57); COMMUNITY_PREMIUM_PRICE_PER_DAY = communityBoardConfig.getInt("CommunityPremiumPricePerDay", 1000000); final String[] allowedBuffs = communityBoardConfig.getString("CommunityAvailableBuffs", "").split(","); - COMMUNITY_AVAILABLE_BUFFS = new ArrayList<>(allowedBuffs.length); + COMMUNITY_AVAILABLE_BUFFS = new HashSet<>(allowedBuffs.length); for (String s : allowedBuffs) { COMMUNITY_AVAILABLE_BUFFS.add(Integer.parseInt(s)); @@ -3401,7 +3401,7 @@ public class Config if (ENABLE_RANDOM_MONSTER_SPAWNS) { final String[] mobsIds = randomSpawnsConfig.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); - MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + MOBS_LIST_NOT_RANDOM = new HashSet<>(mobsIds.length); for (String id : mobsIds) { MOBS_LIST_NOT_RANDOM.add(Integer.parseInt(id)); diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java index d6e0183c6f..c3977185b4 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java @@ -202,8 +202,7 @@ public class ClanHallData implements IXmlReader final Door door = DoorData.getInstance().getDoor(doorId); for (ClanHall ch : _clanHalls.values()) { - final List doors = ch.getDoors(); - if ((doors != null) && doors.contains(door)) + if (ch.getDoors().contains(door)) { return ch; } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java index 6aa0a1fdde..fb395b9e2d 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java @@ -17,10 +17,10 @@ package org.l2jmobius.gameserver.data.xml; import java.io.File; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -42,7 +42,7 @@ public class FakePlayerData implements IXmlReader private final Map _fakePlayerInfos = new HashMap<>(); private final Map _fakePlayerNames = new HashMap<>(); private final Map _fakePlayerIds = new HashMap<>(); - private final List _talkableFakePlayerNames = new ArrayList<>(); + private final Set _talkableFakePlayerNames = new HashSet<>(); protected FakePlayerData() { diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java index d335b95954..1122d7b9ba 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java @@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -49,7 +51,7 @@ import org.l2jmobius.gameserver.util.Util; public class SellBuffsManager implements IXmlReader { private static final Logger LOGGER = Logger.getLogger(SellBuffsManager.class.getName()); - private static final List ALLOWED_BUFFS = new ArrayList<>(); + private static final Set ALLOWED_BUFFS = new HashSet<>(); private static final String HTML_FOLDER = "data/html/mods/SellBuffs/"; protected SellBuffsManager() @@ -76,11 +78,7 @@ public class SellBuffsManager implements IXmlReader { final Element elem = (Element) node.item(i); final int skillId = Integer.parseInt(elem.getAttribute("id")); - - if (!ALLOWED_BUFFS.contains(skillId)) - { - ALLOWED_BUFFS.add(skillId); - } + ALLOWED_BUFFS.add(skillId); } } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java index b10f75ef3d..1e45a21319 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java @@ -19,8 +19,10 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; @@ -67,7 +69,7 @@ public class WalkingManager implements IXmlReader public static final byte REPEAT_TELE_FIRST = 2; public static final byte REPEAT_RANDOM = 3; - private final List _targetedNpcIds = new ArrayList<>(); + private final Set _targetedNpcIds = new HashSet<>(); private final Map _routes = new HashMap<>(); // all available routes private final Map _activeRoutes = new HashMap<>(); // each record represents NPC, moving by predefined route from _routes, and moving progress private final Map _routesToAttach = new HashMap<>(); // each record represents NPC and all available routes for it diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/BlockList.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/BlockList.java index 1af9941ed5..9ac6266e22 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/BlockList.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/BlockList.java @@ -19,9 +19,9 @@ package org.l2jmobius.gameserver.model; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -36,10 +36,11 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; public class BlockList { private static final Logger LOGGER = Logger.getLogger(BlockList.class.getName()); - private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); + + private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); private final Player _owner; - private List _blockList; + private Set _blockList; public BlockList(Player owner) { @@ -68,9 +69,9 @@ public class BlockList OFFLINE_LIST.put(_owner.getObjectId(), _blockList); } - private static List loadList(int objId) + private static Set loadList(int objId) { - final List list = new ArrayList<>(); + final Set list = new HashSet<>(); try (Connection con = DatabaseFactory.getConnection(); PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1")) { @@ -158,7 +159,7 @@ public class BlockList _owner.setMessageRefusal(value); } - private List getBlockList() + private Set getBlockList() { return _blockList; } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/PetData.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/PetData.java index b534c21f36..231b85e85f 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/PetData.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/PetData.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; import org.l2jmobius.gameserver.model.holders.SkillHolder; @@ -40,7 +42,7 @@ public class PetData private int _minLevel = Byte.MAX_VALUE; private int _maxLevel = 0; private boolean _syncLevel = false; - private final List _food = new ArrayList<>(); + private final Set _food = new HashSet<>(); public PetData(int npcId, int itemId) { @@ -133,7 +135,7 @@ public class PetData /** * @return the pet's food list. */ - public List getFood() + public Set getFood() { return _food; } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/SkillLearn.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/SkillLearn.java index a69d30f105..3d5704b5f2 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/SkillLearn.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/SkillLearn.java @@ -16,9 +16,8 @@ */ package org.l2jmobius.gameserver.model; -import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashSet; -import java.util.List; import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -40,12 +39,12 @@ public class SkillLearn private final int _getDualClassLevel; private final boolean _autoGet; private final long _levelUpSp; - private final List _requiredItems = new ArrayList<>(); - private final List _races = new ArrayList<>(); - private final List _preReqSkills = new ArrayList<>(); + private final Set _requiredItems = new HashSet<>(1); + private final Set _races = EnumSet.noneOf(Race.class); + private final Set _preReqSkills = new HashSet<>(1); private SocialClass _socialClass; private final boolean _residenceSkill; - private final List _residenceIds = new ArrayList<>(); + private final Set _residenceIds = new HashSet<>(1); private final boolean _learnedByNpc; private final boolean _learnedByFS; private final Set _removeSkills = new HashSet<>(1); @@ -133,9 +132,9 @@ public class SkillLearn } /** - * @return the list with the item holders required to acquire this skill. + * @return the set with the item holders required to acquire this skill. */ - public List getRequiredItems() + public Set getRequiredItems() { return _requiredItems; } @@ -150,9 +149,9 @@ public class SkillLearn } /** - * @return a list with the races that can acquire this skill. + * @return a set with the races that can acquire this skill. */ - public List getRaces() + public Set getRaces() { return _races; } @@ -167,9 +166,9 @@ public class SkillLearn } /** - * @return the list of skill holders required to acquire this skill. + * @return the set of skill holders required to acquire this skill. */ - public List getPreReqSkills() + public Set getPreReqSkills() { return _preReqSkills; } @@ -212,9 +211,9 @@ public class SkillLearn } /** - * @return a list with the Ids where this skill is available. + * @return a set with the Ids where this skill is available. */ - public List getResidenceIds() + public Set getResidenceIds() { return _residenceIds; } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java index d80071ca22..b088c8b8c9 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java @@ -22,7 +22,6 @@ import java.sql.ResultSet; import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.List; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; @@ -153,7 +152,7 @@ public class Pet extends Summon broadcastStatusUpdate(); - final List foodIds = getPetData().getFood(); + final Set foodIds = getPetData().getFood(); if (foodIds.isEmpty()) { if (isUncontrollable()) diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java index 11efe435d8..1ed0ee81a4 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java @@ -16,8 +16,8 @@ */ package org.l2jmobius.gameserver.model.actor.instance; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import org.l2jmobius.commons.threads.ThreadPool; @@ -57,7 +57,7 @@ public class Trap extends Npc private boolean _isTriggered; private final int _lifeTime; private Player _owner; - private final List _playersWhoDetectedMe = new ArrayList<>(); + private final Set _playersWhoDetectedMe = new HashSet<>(); private final SkillHolder _skill; private int _remainingTime; // Tasks diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java index 71ef076212..3ba8c20a9b 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor.tasks.player; -import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -69,11 +69,12 @@ public class PetFeedTask implements Runnable _player.sendPacket(SystemMessageId.YOU_ARE_OUT_OF_FEED_MOUNT_STATUS_CANCELED); } - final List foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); + final Set foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); if (foodIds.isEmpty()) { return; } + Item food = null; for (int id : foodIds) { diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java index 50d2a821c3..2611b5f121 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.actor.Creature; @@ -29,9 +29,9 @@ import org.l2jmobius.gameserver.model.zone.ZoneType; */ public class ConditionPlayerInsideZoneId extends Condition { - private final List _zones; + private final Set _zones; - public ConditionPlayerInsideZoneId(List zones) + public ConditionPlayerInsideZoneId(Set zones) { _zones = zones; } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java index c15065eca2..d644f663f5 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Player; @@ -29,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerInstanceId extends Condition { - private final List _instanceIds; + private final Set _instanceIds; /** * Instantiates a new condition player instance id. * @param instanceIds the instance ids */ - public ConditionPlayerInstanceId(List instanceIds) + public ConditionPlayerInstanceId(Set instanceIds) { _instanceIds = instanceIds; } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java index 14d61089ed..7c375ec45e 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -28,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerRace extends Condition { - private final Race[] _races; + private final Set _races; /** * Instantiates a new condition player race. * @param races the list containing the allowed races. */ - public ConditionPlayerRace(Race[] races) + public ConditionPlayerRace(Set races) { _races = races; } @@ -46,6 +47,6 @@ public class ConditionPlayerRace extends Condition { return false; } - return CommonUtil.contains(_races, effector.getActingPlayer().getRace()); + return _races.contains(effector.getActingPlayer().getRace()); } } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java index 0f54766571..0b326e3f40 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId())) + if (_npcIds.contains(target.getId())) { existNpc = true; break; diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java index c5c9b5ff0e..db64b6bd7b 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromSummonedNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromSummonedNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromSummonedNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromSummonedNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId()) && (effector == target.getSummoner())) + if (_npcIds.contains(target.getId()) && (effector == target.getSummoner())) { existNpc = true; break; diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java index a3fb0f5374..a47b4b4983 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetClassIdRestriction extends Condition { - private final List _classIds; + private final Set _classIds; /** * Instantiates a new condition target class id restriction. * @param classId the class id */ - public ConditionTargetClassIdRestriction(List classId) + public ConditionTargetClassIdRestriction(Set classId) { _classIds = classId; } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java index 82b1bd5877..9bb694f4ef 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetNpcId extends Condition { - private final List _npcIds; + private final Set _npcIds; /** * Instantiates a new condition target npc id. * @param npcIds the npc ids */ - public ConditionTargetNpcId(List npcIds) + public ConditionTargetNpcId(Set npcIds) { _npcIds = npcIds; } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java index f26329bc21..5c86f26ae5 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.holders; -import java.util.Collection; +import java.util.Set; /** * @author Mobius @@ -25,9 +25,9 @@ public class EventDropHolder extends DropHolder { private final int _minLevel; private final int _maxLevel; - private final Collection _monsterIds; + private final Set _monsterIds; - public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Collection monsterIds) + public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Set monsterIds) { super(null, itemId, min, max, chance); _minLevel = minLevel; @@ -45,7 +45,7 @@ public class EventDropHolder extends DropHolder return _maxLevel; } - public Collection getMonsterIds() + public Set getMonsterIds() { return _monsterIds; } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/item/Henna.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/item/Henna.java index 107656dba9..3fa8d06bc6 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/item/Henna.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/item/Henna.java @@ -17,9 +17,11 @@ package org.l2jmobius.gameserver.model.item; import java.util.ArrayList; -import java.util.HashMap; +import java.util.EnumMap; +import java.util.EnumSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.enums.ClassId; import org.l2jmobius.gameserver.model.StatSet; @@ -34,14 +36,14 @@ public class Henna { private final int _dyeId; private final int _dyeItemId; - private final Map _baseStats = new HashMap<>(); + private final Map _baseStats = new EnumMap<>(BaseStat.class); private final int _wearFee; private final int _wearCount; private final int _cancelFee; private final int _cancelCount; private final int _duration; private final List _skills; - private final List _wearClass; + private final Set _wearClass; public Henna(StatSet set) { @@ -59,7 +61,7 @@ public class Henna _cancelCount = set.getInt("cancel_count"); _duration = set.getInt("duration", -1); _skills = new ArrayList<>(); - _wearClass = new ArrayList<>(); + _wearClass = EnumSet.noneOf(ClassId.class); } /** @@ -147,7 +149,7 @@ public class Henna /** * @return the list with the allowed classes to wear this dye. */ - public List getAllowedWearClass() + public Set getAllowedWearClass() { return _wearClass; } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java index 18d7b61ca2..65402c4c89 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java @@ -17,9 +17,10 @@ package org.l2jmobius.gameserver.model.item.appearance; import java.time.Duration; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.enums.Race; @@ -47,12 +48,12 @@ public class AppearanceStone private final ArmorType _armorType; private final AppearanceHandType _handType; private final AppearanceMagicType _magicType; - private List _crystalTypes; - private List _targetTypes; - private List _bodyParts; - private List _races; - private List _racesNot; - private List _allVisualIds; + private Set _crystalTypes; + private Set _targetTypes; + private Set _bodyParts; + private Set _races; + private Set _racesNot; + private Set _allVisualIds; public AppearanceStone(StatSet set) { @@ -172,35 +173,35 @@ public class AppearanceStone { if (_crystalTypes == null) { - _crystalTypes = new ArrayList<>(); + _crystalTypes = EnumSet.noneOf(CrystalType.class); } _crystalTypes.add(type); } - public List getCrystalTypes() + public Set getCrystalTypes() { - return _crystalTypes != null ? _crystalTypes : Collections.emptyList(); + return _crystalTypes != null ? _crystalTypes : Collections.emptySet(); } public void addTargetType(AppearanceTargetType type) { if (_targetTypes == null) { - _targetTypes = new ArrayList<>(); + _targetTypes = EnumSet.noneOf(AppearanceTargetType.class); } _targetTypes.add(type); } - public List getTargetTypes() + public Set getTargetTypes() { - return _targetTypes != null ? _targetTypes : Collections.emptyList(); + return _targetTypes != null ? _targetTypes : Collections.emptySet(); } public void addBodyPart(Integer part) { if (_bodyParts == null) { - _bodyParts = new ArrayList<>(); + _bodyParts = new HashSet<>(); } _bodyParts.add(part); } @@ -209,47 +210,47 @@ public class AppearanceStone { if (_allVisualIds == null) { - _allVisualIds = new ArrayList<>(); + _allVisualIds = new HashSet<>(); } _allVisualIds.add(appearanceHolder); } - public List getVisualIds() + public Set getVisualIds() { - return _allVisualIds != null ? _allVisualIds : Collections.emptyList(); + return _allVisualIds != null ? _allVisualIds : Collections.emptySet(); } - public List getBodyParts() + public Set getBodyParts() { - return _bodyParts != null ? _bodyParts : Collections.emptyList(); + return _bodyParts != null ? _bodyParts : Collections.emptySet(); } public void addRace(Race race) { if (_races == null) { - _races = new ArrayList<>(); + _races = EnumSet.noneOf(Race.class); } _races.add(race); } - public List getRaces() + public Set getRaces() { - return _races != null ? _races : Collections.emptyList(); + return _races != null ? _races : Collections.emptySet(); } public void addRaceNot(Race race) { if (_racesNot == null) { - _racesNot = new ArrayList<>(); + _racesNot = EnumSet.noneOf(Race.class); } _racesNot.add(race); } - public List getRacesNot() + public Set getRacesNot() { - return _racesNot != null ? _racesNot : Collections.emptyList(); + return _racesNot != null ? _racesNot : Collections.emptySet(); } /** @@ -302,7 +303,7 @@ public class AppearanceStone { // Seems like in retail item with already changed appearance, can be changed again without being restored. - final AppearanceTargetType targetType = getTargetTypes().get(0); + final AppearanceTargetType targetType = getTargetTypes().stream().findFirst().get(); switch (targetType) { case NONE: diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java index 5d3a79d524..5e067a67e5 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java @@ -16,16 +16,16 @@ */ package org.l2jmobius.gameserver.model.item.enchant; +import java.util.EnumSet; +import java.util.Set; import java.util.logging.Logger; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.item.ItemTemplate; import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.model.item.type.CrystalType; import org.l2jmobius.gameserver.model.item.type.EtcItemType; -import org.l2jmobius.gameserver.model.item.type.ItemType; /** * @author UnAfraid @@ -34,26 +34,27 @@ public abstract class AbstractEnchantItem { protected static final Logger LOGGER = Logger.getLogger(AbstractEnchantItem.class.getName()); - private static final ItemType[] ENCHANT_TYPES = new ItemType[] + private static final Set ENCHANT_TYPES = EnumSet.noneOf(EtcItemType.class); + static { - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM, - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP, - EtcItemType.BLESS_ENCHT_AM, - EtcItemType.BLESS_ENCHT_AM_DOWN, - EtcItemType.BLESS_ENCHT_WP, - EtcItemType.ENCHT_AM, - EtcItemType.ENCHT_WP, - EtcItemType.GIANT_ENCHT_AM, - EtcItemType.GIANT_ENCHT_WP, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - }; + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + } private final int _id; private final CrystalType _grade; @@ -71,7 +72,7 @@ public abstract class AbstractEnchantItem { throw new NullPointerException(); } - else if (!CommonUtil.contains(ENCHANT_TYPES, getItem().getItemType())) + else if (!ENCHANT_TYPES.contains(getItem().getItemType())) { throw new IllegalAccessError(); } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java index 5ba6755084..18508d0145 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java @@ -24,8 +24,10 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Set; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -184,7 +186,7 @@ public class LongTimeEvent extends Quest final Node maxLevelNode = d.getAttributes().getNamedItem("maxLevel"); final int maxLevel = maxLevelNode == null ? Integer.MAX_VALUE : Integer.parseInt(maxLevelNode.getNodeValue()); final Node monsterIdsNode = d.getAttributes().getNamedItem("monsterIds"); - final List monsterIds = new ArrayList<>(); + final Set monsterIds = new HashSet<>(); if (monsterIdsNode != null) { for (String id : monsterIdsNode.getNodeValue().split(",")) diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/residences/ClanHall.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/residences/ClanHall.java index 0c0a529077..fcc850371b 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/residences/ClanHall.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/residences/ClanHall.java @@ -23,7 +23,9 @@ import java.sql.SQLException; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -61,9 +63,9 @@ public class ClanHall extends AbstractResidence private final int _minBid; final int _lease; private final int _deposit; - private final List _npcs; - private final List _doors; - private final List _teleports; + private final Set _npcs = new HashSet<>(); + private final Set _doors = new HashSet<>(); + private final Set _teleports = new HashSet<>(); private final Location _ownerLocation; private final Location _banishLocation; // Dynamic parameters @@ -85,9 +87,21 @@ public class ClanHall extends AbstractResidence _minBid = params.getInt("minBid"); _lease = params.getInt("lease"); _deposit = params.getInt("deposit"); - _npcs = params.getList("npcList", Integer.class); - _doors = params.getList("doorList", Door.class); - _teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + final List npcs = params.getList("npcList", Integer.class); + if (npcs != null) + { + _npcs.addAll(npcs); + } + final List doors = params.getList("doorList", Door.class); + if (doors != null) + { + _doors.addAll(doors); + } + final List teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + if (teleports != null) + { + _teleports.addAll(teleports); + } _ownerLocation = params.getLocation("owner_loc"); _banishLocation = params.getLocation("banish_loc"); // Set dynamic parameters (from DB) @@ -196,7 +210,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Door} related to this {@link ClanHall}. * @return all {@link Door} related to this {@link ClanHall} */ - public List getDoors() + public Set getDoors() { return _doors; } @@ -205,7 +219,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Npc} related to this {@link ClanHall}. * @return all {@link Npc} related to this {@link ClanHall} */ - public List getNpcs() + public Set getNpcs() { return _npcs; } @@ -324,7 +338,7 @@ public class ClanHall extends AbstractResidence return _banishLocation; } - public List getTeleportList() + public Set getTeleportList() { return _teleports; } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/siege/Castle.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/siege/Castle.java index d053196bec..4e90413baf 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/siege/Castle.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/siege/Castle.java @@ -21,8 +21,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.Calendar; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -83,7 +85,7 @@ public class Castle extends AbstractResidence private SiegeZone _zone = null; private ResidenceTeleportZone _teleZone; private Clan _formerOwner = null; - private final List _artefacts = new ArrayList<>(1); + private final Set _artefacts = new HashSet<>(1); private final Map _function = new ConcurrentHashMap<>(); private int _ticketBuyCount = 0; private boolean _isFirstMidVictory = false; @@ -1072,7 +1074,7 @@ public class Castle extends AbstractResidence _artefacts.add(artefact); } - public List getArtefacts() + public Set getArtefacts() { return _artefacts; } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java index 0c79677eae..4ebf954ee5 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.network.serverpackets; -import java.util.List; +import java.util.Set; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.gameserver.data.sql.CharNameTable; @@ -27,19 +27,19 @@ import org.l2jmobius.gameserver.network.OutgoingPackets; */ public class BlockListPacket implements IClientOutgoingPacket { - private final List _playersId; + private final Set _playerIds; - public BlockListPacket(List playersId) + public BlockListPacket(Set playerIds) { - _playersId = playersId; + _playerIds = playerIds; } @Override public boolean write(PacketWriter packet) { OutgoingPackets.BLOCK_LIST.writeId(packet); - packet.writeD(_playersId.size()); - for (int playerId : _playersId) + packet.writeD(_playerIds.size()); + for (int playerId : _playerIds) { packet.writeS(CharNameTable.getInstance().getNameById(playerId)); packet.writeS(""); // memo ? diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java index 8555bb6e86..eb5bfd05d8 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.network.serverpackets; import java.util.List; import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; import org.l2jmobius.commons.network.PacketWriter; @@ -37,7 +38,7 @@ public class ExAcquireSkillInfo implements IClientOutgoingPacket private final int _dualClassLevel; private final long _spCost; private final int _minLevel; - private final List _itemReq; + private final Set _itemReq; private final List _skillRem; /** diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java index 84b5fead76..a163a85735 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java @@ -35,7 +35,7 @@ public class ExChooseShapeShiftingItem implements IClientOutgoingPacket public ExChooseShapeShiftingItem(AppearanceStone stone) { _type = stone.getType(); - _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().get(0); + _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().stream().findFirst().get(); _itemId = stone.getId(); } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/DocumentBase.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/DocumentBase.java index 8a8e13d940..c22140b9c4 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/DocumentBase.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/DocumentBase.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.util; import java.io.File; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -390,12 +391,12 @@ public abstract class DocumentBase case "races": { final String[] racesVal = a.getNodeValue().split(","); - final Race[] races = new Race[racesVal.length]; + final Set races = EnumSet.noneOf(Race.class); for (int r = 0; r < racesVal.length; r++) { if (racesVal[r] != null) { - races[r] = Race.valueOf(racesVal[r]); + races.add(Race.valueOf(racesVal[r])); } } cond = joinAnd(cond, new ConditionPlayerRace(races)); @@ -671,13 +672,13 @@ public abstract class DocumentBase case "instanceid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final ArrayList array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInstanceId(array)); + cond = joinAnd(cond, new ConditionPlayerInstanceId(set)); break; } case "agathionid": @@ -728,10 +729,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -745,10 +746,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -834,13 +835,13 @@ public abstract class DocumentBase case "insidezoneid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInsideZoneId(array)); + cond = joinAnd(cond, new ConditionPlayerInsideZoneId(set)); break; } case "checkabnormal": @@ -961,13 +962,13 @@ public abstract class DocumentBase case "class_id_restriction": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetClassIdRestriction(array)); + cond = joinAnd(cond, new ConditionTargetClassIdRestriction(set)); break; } case "active_effect_id": @@ -1045,13 +1046,13 @@ public abstract class DocumentBase case "npcid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetNpcId(array)); + cond = joinAnd(cond, new ConditionTargetNpcId(set)); break; } case "npctype": diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/bypasshandlers/Link.java b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/bypasshandlers/Link.java index 380a9f1ae3..93bc7f3647 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/bypasshandlers/Link.java +++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/bypasshandlers/Link.java @@ -16,7 +16,9 @@ */ package handlers.bypasshandlers; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.HashSet; +import java.util.Set; + import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.handler.IBypassHandler; import org.l2jmobius.gameserver.model.actor.Creature; @@ -31,37 +33,38 @@ public class Link implements IBypassHandler "Link" }; - private static final String[] VALID_LINKS = + private static final Set VALID_LINKS = new HashSet<>(); + static { - "common/craft_01.htm", - "common/craft_02.htm", - "common/runes_01.htm", - "common/sealed_runes_01.htm", - "common/sealed_runes_02.htm", - "common/sealed_runes_03.htm", - "common/sealed_runes_04.htm", - "common/sealed_runes_05.htm", - "common/sealed_runes_06.htm", - "common/sealed_runes_07.htm", - "common/sealed_runes_08.htm", - "common/sealed_runes_09.htm", - "common/skill_enchant_help_01.htm", - "common/skill_enchant_help_02.htm", - "common/skill_enchant_help_03.htm", - "default/BlessingOfProtection.htm", - "default/SupportMagic.htm", - "fisherman/fishing_manual001.htm", - "fisherman/fishing_manual002.htm", - "fisherman/fishing_manual003.htm", - "fisherman/fishing_manual004.htm", - "fisherman/fishing_manual005.htm", - "fortress/foreman.htm", - "petmanager/evolve.htm", - "petmanager/exchange.htm", - "petmanager/instructions.htm", - "warehouse/clanwh.htm", - "warehouse/privatewh.htm", - }; + VALID_LINKS.add("common/craft_01.htm"); + VALID_LINKS.add("common/craft_02.htm"); + VALID_LINKS.add("common/runes_01.htm"); + VALID_LINKS.add("common/runes_01.htm"); + VALID_LINKS.add("common/sealed_runes_02.htm"); + VALID_LINKS.add("common/sealed_runes_03.htm"); + VALID_LINKS.add("common/sealed_runes_04.htm"); + VALID_LINKS.add("common/sealed_runes_05.htm"); + VALID_LINKS.add("common/sealed_runes_06.htm"); + VALID_LINKS.add("common/sealed_runes_07.htm"); + VALID_LINKS.add("common/sealed_runes_08.htm"); + VALID_LINKS.add("common/sealed_runes_09.htm"); + VALID_LINKS.add("common/skill_enchant_help_01.htm"); + VALID_LINKS.add("common/skill_enchant_help_02.htm"); + VALID_LINKS.add("common/skill_enchant_help_03.htm"); + VALID_LINKS.add("default/BlessingOfProtection.htm"); + VALID_LINKS.add("default/SupportMagic.htm"); + VALID_LINKS.add("fisherman/fishing_manual001.htm"); + VALID_LINKS.add("fisherman/fishing_manual002.htm"); + VALID_LINKS.add("fisherman/fishing_manual003.htm"); + VALID_LINKS.add("fisherman/fishing_manual004.htm"); + VALID_LINKS.add("fisherman/fishing_manual008.htm"); + VALID_LINKS.add("fortress/foreman.htm"); + VALID_LINKS.add("petmanager/evolve.htm"); + VALID_LINKS.add("petmanager/exchange.htm"); + VALID_LINKS.add("petmanager/instructions.htm"); + VALID_LINKS.add("warehouse/clanwh.htm"); + VALID_LINKS.add("warehouse/privatewh.htm"); + } @Override public boolean useBypass(String command, Player player, Creature target) @@ -79,12 +82,13 @@ public class Link implements IBypassHandler return false; } - String content = CommonUtil.contains(VALID_LINKS, htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; + String content = VALID_LINKS.contains(htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; // Precaution. if (htmlPath.startsWith("teleporter/") && !(player.getTarget() instanceof Teleporter)) { content = null; } + final NpcHtmlMessage html = new NpcHtmlMessage(target != null ? target.getObjectId() : 0); if (content != null) { diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/itemhandlers/PetFood.java b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/itemhandlers/PetFood.java index 3c5572d4ec..8b908ea095 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/itemhandlers/PetFood.java +++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/itemhandlers/PetFood.java @@ -17,6 +17,7 @@ package handlers.itemhandlers; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.PetDataTable; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -79,7 +80,7 @@ public class PetFood implements IItemHandler final Player player = activeChar.getActingPlayer(); if (player.isMounted()) { - final List foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); + final Set foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); if (foodIds.contains(item.getId()) && player.destroyItem("Consume", item.getObjectId(), 1, null, false)) { player.broadcastPacket(new MagicSkillUse(player, player, skillId, skillLevel, 0, 0)); diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java index 2ad282f683..99f45fbb41 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java +++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.ClanHallData; import org.l2jmobius.gameserver.model.StatSet; @@ -32,12 +33,12 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpCheckResidenceSkillCondition implements ISkillCondition { - private final List _residencesId; + private final Set _residencesId = new HashSet<>(); private final boolean _isWithin; public OpCheckResidenceSkillCondition(StatSet params) { - _residencesId = params.getList("residencesId", Integer.class); + _residencesId.addAll(params.getList("residencesId", Integer.class)); _isWithin = params.getBoolean("isWithin"); } diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java index fc2934423b..4a8282d988 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java +++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java @@ -16,9 +16,9 @@ */ package handlers.skillconditionhandlers; -import java.util.ArrayList; -import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -28,18 +28,18 @@ import org.l2jmobius.gameserver.model.skill.ISkillCondition; import org.l2jmobius.gameserver.model.skill.Skill; /** - * @author UnAfraid + * @author UnAfraid, Mobius */ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition { - private final List _npcIds = new ArrayList<>(); + private final Set _npcIds = new HashSet<>(); public OpNeedSummonOrPetSkillCondition(StatSet params) { - final List npcIds = params.getList("npcIds", String.class); + final List npcIds = params.getList("npcIds", Integer.class); if (npcIds != null) { - npcIds.stream().map(Integer::valueOf).forEach(_npcIds::add); + _npcIds.addAll(npcIds); } } @@ -47,7 +47,19 @@ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition public boolean canUse(Creature caster, Skill skill, WorldObject target) { final Summon pet = caster.getPet(); - final Collection summons = caster.getServitors().values(); - return ((pet != null) && _npcIds.stream().anyMatch(npcId -> npcId == pet.getId())) || summons.stream().anyMatch(summon -> _npcIds.contains(summon.getId())); + if ((pet != null) && _npcIds.contains(pet.getId())) + { + return true; + } + + for (Summon summon : caster.getServitors().values()) + { + if (_npcIds.contains(summon.getId())) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java index 8541bc62b4..ef81b291d4 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java +++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,11 +30,11 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetDoorSkillCondition implements ISkillCondition { - private final List _doorIds; + private final Set _doorIds = new HashSet<>(); public OpTargetDoorSkillCondition(StatSet params) { - _doorIds = params.getList("doorIds", Integer.class); + _doorIds.addAll(params.getList("doorIds", Integer.class)); } @Override diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java index 3ce4145703..0ccd571e19 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java +++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,17 +30,17 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetNpcSkillCondition implements ISkillCondition { - private final List _npcId; + private final Set _npcIds = new HashSet<>(); public OpTargetNpcSkillCondition(StatSet params) { - _npcId = params.getList("npcIds", Integer.class); + _npcIds.addAll(params.getList("npcIds", Integer.class)); } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget(); - return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId()); + return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcIds.contains(actualTarget.getId()); } } diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/instances/AbstractInstance.java b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/instances/AbstractInstance.java index 94c337f0df..a5b4ef238a 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/instances/AbstractInstance.java +++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/instances/AbstractInstance.java @@ -16,9 +16,10 @@ */ package instances; +import java.util.HashSet; import java.util.List; +import java.util.Set; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.enums.InstanceReenterType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.instancemanager.InstanceManager; @@ -40,25 +41,29 @@ import ai.AbstractNpcAI; */ public abstract class AbstractInstance extends AbstractNpcAI { - private final int[] _templateIds; + private final Set _templateIds = new HashSet<>(); - public AbstractInstance(int... templateId) + public AbstractInstance(int... templateIds) { - if (templateId.length == 0) + if (templateIds.length == 0) { throw new IllegalStateException("No template ids were provided!"); } - _templateIds = templateId; + + for (int templateId : templateIds) + { + _templateIds.add(templateId); + } } - public int[] getTemplateId() + public Set getTemplateId() { return _templateIds; } public boolean isInInstance(Instance instance) { - return (instance != null) && CommonUtil.contains(_templateIds, instance.getTemplateId()); + return (instance != null) && _templateIds.contains(instance.getTemplateId()); } /** diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/Config.java index b6cb0dd517..5fc621eded 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/Config.java @@ -286,7 +286,7 @@ public class Config public static boolean AUTO_LOOT_SLOT_LIMIT; public static int LOOT_RAIDS_PRIVILEGE_INTERVAL; public static int LOOT_RAIDS_PRIVILEGE_CC_SIZE; - public static List AUTO_LOOT_ITEM_IDS; + public static Set AUTO_LOOT_ITEM_IDS; public static boolean ENABLE_KEYBOARD_MOVEMENT; public static int UNSTUCK_INTERVAL; public static int TELEPORT_WATCHDOG_TIMEOUT; @@ -476,7 +476,7 @@ public class Config public static boolean ALLOW_DISCARDITEM; public static int AUTODESTROY_ITEM_AFTER; public static int HERB_AUTO_DESTROY_TIME; - public static List LIST_PROTECTED_ITEMS; + public static Set LIST_PROTECTED_ITEMS; public static boolean DATABASE_CLEAN_UP; public static int CHAR_DATA_STORE_INTERVAL; public static int CLAN_VARIABLES_STORE_INTERVAL; @@ -567,7 +567,7 @@ public class Config public static boolean ALT_OLY_LOG_FIGHTS; public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS; public static boolean ALT_OLY_ANNOUNCE_GAMES; - public static List LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(); + public static Set LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(); public static int ALT_OLY_WEAPON_ENCHANT_LIMIT; public static int ALT_OLY_ARMOR_ENCHANT_LIMIT; public static int ALT_OLY_WAIT_TIME; @@ -1160,9 +1160,9 @@ public class Config public static int AUTO_CP_PERCENTAGE; public static int AUTO_HP_PERCENTAGE; public static int AUTO_MP_PERCENTAGE; - public static List AUTO_CP_ITEM_IDS; - public static List AUTO_HP_ITEM_IDS; - public static List AUTO_MP_ITEM_IDS; + public static Set AUTO_CP_ITEM_IDS; + public static Set AUTO_HP_ITEM_IDS; + public static Set AUTO_MP_ITEM_IDS; public static boolean CUSTOM_STARTING_LOC; public static int CUSTOM_STARTING_LOC_X; public static int CUSTOM_STARTING_LOC_Y; @@ -1172,7 +1172,7 @@ public class Config public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; public static int MOB_MIN_SPAWN_RANGE; public static int MOB_MAX_SPAWN_RANGE; - public static List MOBS_LIST_NOT_RANDOM; + public static Set MOBS_LIST_NOT_RANDOM; public static boolean FREE_JUMPS_FOR_ALL; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; @@ -1191,7 +1191,7 @@ public class Config public static boolean COMMUNITY_PREMIUM_SYSTEM_ENABLED; public static int COMMUNITY_PREMIUM_COIN_ID; public static int COMMUNITY_PREMIUM_PRICE_PER_DAY; - public static List COMMUNITY_AVAILABLE_BUFFS; + public static Set COMMUNITY_AVAILABLE_BUFFS; public static Map COMMUNITY_AVAILABLE_TELEPORTS; public static boolean CUSTOM_DEPOSITABLE_ENABLED; public static boolean CUSTOM_DEPOSITABLE_QUEST_ITEMS; @@ -1839,7 +1839,7 @@ public class Config LOOT_RAIDS_PRIVILEGE_INTERVAL = characterConfig.getInt("RaidLootRightsInterval", 900) * 1000; LOOT_RAIDS_PRIVILEGE_CC_SIZE = characterConfig.getInt("RaidLootRightsCCSize", 45); final String[] autoLootItemIds = characterConfig.getString("AutoLootItemIds", "0").split(","); - AUTO_LOOT_ITEM_IDS = new ArrayList<>(autoLootItemIds.length); + AUTO_LOOT_ITEM_IDS = new HashSet<>(autoLootItemIds.length); for (String item : autoLootItemIds) { Integer itm = 0; @@ -1959,7 +1959,7 @@ public class Config AUTODESTROY_ITEM_AFTER = generalConfig.getInt("AutoDestroyDroppedItemAfter", 600); HERB_AUTO_DESTROY_TIME = generalConfig.getInt("AutoDestroyHerbTime", 60) * 1000; final String[] split = generalConfig.getString("ListOfProtectedItems", "0").split(","); - LIST_PROTECTED_ITEMS = new ArrayList<>(split.length); + LIST_PROTECTED_ITEMS = new HashSet<>(split.length); for (String id : split) { LIST_PROTECTED_ITEMS.add(Integer.parseInt(id)); @@ -2353,7 +2353,7 @@ public class Config if (!olyRestrictedItems.isEmpty()) { final String[] olyRestrictedItemsSplit = olyRestrictedItems.split(","); - LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(olyRestrictedItemsSplit.length); + LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(olyRestrictedItemsSplit.length); for (String id : olyRestrictedItemsSplit) { LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id)); @@ -2467,17 +2467,17 @@ public class Config AUTO_CP_PERCENTAGE = autoPotionsConfig.getInt("AutoCpPercentage", 70); AUTO_HP_PERCENTAGE = autoPotionsConfig.getInt("AutoHpPercentage", 70); AUTO_MP_PERCENTAGE = autoPotionsConfig.getInt("AutoMpPercentage", 70); - AUTO_CP_ITEM_IDS = new ArrayList<>(); + AUTO_CP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoCpItemIds", "0").split(",")) { AUTO_CP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_HP_ITEM_IDS = new ArrayList<>(); + AUTO_HP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoHpItemIds", "0").split(",")) { AUTO_HP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_MP_ITEM_IDS = new ArrayList<>(); + AUTO_MP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoMpItemIds", "0").split(",")) { AUTO_MP_ITEM_IDS.add(Integer.parseInt(s)); @@ -3087,7 +3087,7 @@ public class Config COMMUNITY_PREMIUM_COIN_ID = communityBoardConfig.getInt("CommunityPremiumBuyCoinId", 57); COMMUNITY_PREMIUM_PRICE_PER_DAY = communityBoardConfig.getInt("CommunityPremiumPricePerDay", 1000000); final String[] allowedBuffs = communityBoardConfig.getString("CommunityAvailableBuffs", "").split(","); - COMMUNITY_AVAILABLE_BUFFS = new ArrayList<>(allowedBuffs.length); + COMMUNITY_AVAILABLE_BUFFS = new HashSet<>(allowedBuffs.length); for (String s : allowedBuffs) { COMMUNITY_AVAILABLE_BUFFS.add(Integer.parseInt(s)); @@ -3407,7 +3407,7 @@ public class Config if (ENABLE_RANDOM_MONSTER_SPAWNS) { final String[] mobsIds = randomSpawnsConfig.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); - MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + MOBS_LIST_NOT_RANDOM = new HashSet<>(mobsIds.length); for (String id : mobsIds) { MOBS_LIST_NOT_RANDOM.add(Integer.parseInt(id)); diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java index d6e0183c6f..c3977185b4 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java @@ -202,8 +202,7 @@ public class ClanHallData implements IXmlReader final Door door = DoorData.getInstance().getDoor(doorId); for (ClanHall ch : _clanHalls.values()) { - final List doors = ch.getDoors(); - if ((doors != null) && doors.contains(door)) + if (ch.getDoors().contains(door)) { return ch; } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java index 6aa0a1fdde..fb395b9e2d 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java @@ -17,10 +17,10 @@ package org.l2jmobius.gameserver.data.xml; import java.io.File; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -42,7 +42,7 @@ public class FakePlayerData implements IXmlReader private final Map _fakePlayerInfos = new HashMap<>(); private final Map _fakePlayerNames = new HashMap<>(); private final Map _fakePlayerIds = new HashMap<>(); - private final List _talkableFakePlayerNames = new ArrayList<>(); + private final Set _talkableFakePlayerNames = new HashSet<>(); protected FakePlayerData() { diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java index d335b95954..1122d7b9ba 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java @@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -49,7 +51,7 @@ import org.l2jmobius.gameserver.util.Util; public class SellBuffsManager implements IXmlReader { private static final Logger LOGGER = Logger.getLogger(SellBuffsManager.class.getName()); - private static final List ALLOWED_BUFFS = new ArrayList<>(); + private static final Set ALLOWED_BUFFS = new HashSet<>(); private static final String HTML_FOLDER = "data/html/mods/SellBuffs/"; protected SellBuffsManager() @@ -76,11 +78,7 @@ public class SellBuffsManager implements IXmlReader { final Element elem = (Element) node.item(i); final int skillId = Integer.parseInt(elem.getAttribute("id")); - - if (!ALLOWED_BUFFS.contains(skillId)) - { - ALLOWED_BUFFS.add(skillId); - } + ALLOWED_BUFFS.add(skillId); } } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java index b10f75ef3d..1e45a21319 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java @@ -19,8 +19,10 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; @@ -67,7 +69,7 @@ public class WalkingManager implements IXmlReader public static final byte REPEAT_TELE_FIRST = 2; public static final byte REPEAT_RANDOM = 3; - private final List _targetedNpcIds = new ArrayList<>(); + private final Set _targetedNpcIds = new HashSet<>(); private final Map _routes = new HashMap<>(); // all available routes private final Map _activeRoutes = new HashMap<>(); // each record represents NPC, moving by predefined route from _routes, and moving progress private final Map _routesToAttach = new HashMap<>(); // each record represents NPC and all available routes for it diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/BlockList.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/BlockList.java index 1af9941ed5..9ac6266e22 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/BlockList.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/BlockList.java @@ -19,9 +19,9 @@ package org.l2jmobius.gameserver.model; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -36,10 +36,11 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; public class BlockList { private static final Logger LOGGER = Logger.getLogger(BlockList.class.getName()); - private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); + + private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); private final Player _owner; - private List _blockList; + private Set _blockList; public BlockList(Player owner) { @@ -68,9 +69,9 @@ public class BlockList OFFLINE_LIST.put(_owner.getObjectId(), _blockList); } - private static List loadList(int objId) + private static Set loadList(int objId) { - final List list = new ArrayList<>(); + final Set list = new HashSet<>(); try (Connection con = DatabaseFactory.getConnection(); PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1")) { @@ -158,7 +159,7 @@ public class BlockList _owner.setMessageRefusal(value); } - private List getBlockList() + private Set getBlockList() { return _blockList; } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/PetData.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/PetData.java index b534c21f36..231b85e85f 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/PetData.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/PetData.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; import org.l2jmobius.gameserver.model.holders.SkillHolder; @@ -40,7 +42,7 @@ public class PetData private int _minLevel = Byte.MAX_VALUE; private int _maxLevel = 0; private boolean _syncLevel = false; - private final List _food = new ArrayList<>(); + private final Set _food = new HashSet<>(); public PetData(int npcId, int itemId) { @@ -133,7 +135,7 @@ public class PetData /** * @return the pet's food list. */ - public List getFood() + public Set getFood() { return _food; } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/SkillLearn.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/SkillLearn.java index a69d30f105..3d5704b5f2 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/SkillLearn.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/SkillLearn.java @@ -16,9 +16,8 @@ */ package org.l2jmobius.gameserver.model; -import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashSet; -import java.util.List; import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -40,12 +39,12 @@ public class SkillLearn private final int _getDualClassLevel; private final boolean _autoGet; private final long _levelUpSp; - private final List _requiredItems = new ArrayList<>(); - private final List _races = new ArrayList<>(); - private final List _preReqSkills = new ArrayList<>(); + private final Set _requiredItems = new HashSet<>(1); + private final Set _races = EnumSet.noneOf(Race.class); + private final Set _preReqSkills = new HashSet<>(1); private SocialClass _socialClass; private final boolean _residenceSkill; - private final List _residenceIds = new ArrayList<>(); + private final Set _residenceIds = new HashSet<>(1); private final boolean _learnedByNpc; private final boolean _learnedByFS; private final Set _removeSkills = new HashSet<>(1); @@ -133,9 +132,9 @@ public class SkillLearn } /** - * @return the list with the item holders required to acquire this skill. + * @return the set with the item holders required to acquire this skill. */ - public List getRequiredItems() + public Set getRequiredItems() { return _requiredItems; } @@ -150,9 +149,9 @@ public class SkillLearn } /** - * @return a list with the races that can acquire this skill. + * @return a set with the races that can acquire this skill. */ - public List getRaces() + public Set getRaces() { return _races; } @@ -167,9 +166,9 @@ public class SkillLearn } /** - * @return the list of skill holders required to acquire this skill. + * @return the set of skill holders required to acquire this skill. */ - public List getPreReqSkills() + public Set getPreReqSkills() { return _preReqSkills; } @@ -212,9 +211,9 @@ public class SkillLearn } /** - * @return a list with the Ids where this skill is available. + * @return a set with the Ids where this skill is available. */ - public List getResidenceIds() + public Set getResidenceIds() { return _residenceIds; } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java index d80071ca22..b088c8b8c9 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java @@ -22,7 +22,6 @@ import java.sql.ResultSet; import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.List; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; @@ -153,7 +152,7 @@ public class Pet extends Summon broadcastStatusUpdate(); - final List foodIds = getPetData().getFood(); + final Set foodIds = getPetData().getFood(); if (foodIds.isEmpty()) { if (isUncontrollable()) diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java index 11efe435d8..1ed0ee81a4 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java @@ -16,8 +16,8 @@ */ package org.l2jmobius.gameserver.model.actor.instance; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import org.l2jmobius.commons.threads.ThreadPool; @@ -57,7 +57,7 @@ public class Trap extends Npc private boolean _isTriggered; private final int _lifeTime; private Player _owner; - private final List _playersWhoDetectedMe = new ArrayList<>(); + private final Set _playersWhoDetectedMe = new HashSet<>(); private final SkillHolder _skill; private int _remainingTime; // Tasks diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java index 71ef076212..3ba8c20a9b 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor.tasks.player; -import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -69,11 +69,12 @@ public class PetFeedTask implements Runnable _player.sendPacket(SystemMessageId.YOU_ARE_OUT_OF_FEED_MOUNT_STATUS_CANCELED); } - final List foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); + final Set foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); if (foodIds.isEmpty()) { return; } + Item food = null; for (int id : foodIds) { diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java index 50d2a821c3..2611b5f121 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.actor.Creature; @@ -29,9 +29,9 @@ import org.l2jmobius.gameserver.model.zone.ZoneType; */ public class ConditionPlayerInsideZoneId extends Condition { - private final List _zones; + private final Set _zones; - public ConditionPlayerInsideZoneId(List zones) + public ConditionPlayerInsideZoneId(Set zones) { _zones = zones; } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java index c15065eca2..d644f663f5 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Player; @@ -29,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerInstanceId extends Condition { - private final List _instanceIds; + private final Set _instanceIds; /** * Instantiates a new condition player instance id. * @param instanceIds the instance ids */ - public ConditionPlayerInstanceId(List instanceIds) + public ConditionPlayerInstanceId(Set instanceIds) { _instanceIds = instanceIds; } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java index 14d61089ed..7c375ec45e 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -28,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerRace extends Condition { - private final Race[] _races; + private final Set _races; /** * Instantiates a new condition player race. * @param races the list containing the allowed races. */ - public ConditionPlayerRace(Race[] races) + public ConditionPlayerRace(Set races) { _races = races; } @@ -46,6 +47,6 @@ public class ConditionPlayerRace extends Condition { return false; } - return CommonUtil.contains(_races, effector.getActingPlayer().getRace()); + return _races.contains(effector.getActingPlayer().getRace()); } } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java index 0f54766571..0b326e3f40 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId())) + if (_npcIds.contains(target.getId())) { existNpc = true; break; diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java index c5c9b5ff0e..db64b6bd7b 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromSummonedNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromSummonedNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromSummonedNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromSummonedNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId()) && (effector == target.getSummoner())) + if (_npcIds.contains(target.getId()) && (effector == target.getSummoner())) { existNpc = true; break; diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java index a3fb0f5374..a47b4b4983 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetClassIdRestriction extends Condition { - private final List _classIds; + private final Set _classIds; /** * Instantiates a new condition target class id restriction. * @param classId the class id */ - public ConditionTargetClassIdRestriction(List classId) + public ConditionTargetClassIdRestriction(Set classId) { _classIds = classId; } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java index 82b1bd5877..9bb694f4ef 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetNpcId extends Condition { - private final List _npcIds; + private final Set _npcIds; /** * Instantiates a new condition target npc id. * @param npcIds the npc ids */ - public ConditionTargetNpcId(List npcIds) + public ConditionTargetNpcId(Set npcIds) { _npcIds = npcIds; } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java index f26329bc21..5c86f26ae5 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.holders; -import java.util.Collection; +import java.util.Set; /** * @author Mobius @@ -25,9 +25,9 @@ public class EventDropHolder extends DropHolder { private final int _minLevel; private final int _maxLevel; - private final Collection _monsterIds; + private final Set _monsterIds; - public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Collection monsterIds) + public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Set monsterIds) { super(null, itemId, min, max, chance); _minLevel = minLevel; @@ -45,7 +45,7 @@ public class EventDropHolder extends DropHolder return _maxLevel; } - public Collection getMonsterIds() + public Set getMonsterIds() { return _monsterIds; } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/item/Henna.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/item/Henna.java index 107656dba9..3fa8d06bc6 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/item/Henna.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/item/Henna.java @@ -17,9 +17,11 @@ package org.l2jmobius.gameserver.model.item; import java.util.ArrayList; -import java.util.HashMap; +import java.util.EnumMap; +import java.util.EnumSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.enums.ClassId; import org.l2jmobius.gameserver.model.StatSet; @@ -34,14 +36,14 @@ public class Henna { private final int _dyeId; private final int _dyeItemId; - private final Map _baseStats = new HashMap<>(); + private final Map _baseStats = new EnumMap<>(BaseStat.class); private final int _wearFee; private final int _wearCount; private final int _cancelFee; private final int _cancelCount; private final int _duration; private final List _skills; - private final List _wearClass; + private final Set _wearClass; public Henna(StatSet set) { @@ -59,7 +61,7 @@ public class Henna _cancelCount = set.getInt("cancel_count"); _duration = set.getInt("duration", -1); _skills = new ArrayList<>(); - _wearClass = new ArrayList<>(); + _wearClass = EnumSet.noneOf(ClassId.class); } /** @@ -147,7 +149,7 @@ public class Henna /** * @return the list with the allowed classes to wear this dye. */ - public List getAllowedWearClass() + public Set getAllowedWearClass() { return _wearClass; } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java index 18d7b61ca2..65402c4c89 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java @@ -17,9 +17,10 @@ package org.l2jmobius.gameserver.model.item.appearance; import java.time.Duration; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.enums.Race; @@ -47,12 +48,12 @@ public class AppearanceStone private final ArmorType _armorType; private final AppearanceHandType _handType; private final AppearanceMagicType _magicType; - private List _crystalTypes; - private List _targetTypes; - private List _bodyParts; - private List _races; - private List _racesNot; - private List _allVisualIds; + private Set _crystalTypes; + private Set _targetTypes; + private Set _bodyParts; + private Set _races; + private Set _racesNot; + private Set _allVisualIds; public AppearanceStone(StatSet set) { @@ -172,35 +173,35 @@ public class AppearanceStone { if (_crystalTypes == null) { - _crystalTypes = new ArrayList<>(); + _crystalTypes = EnumSet.noneOf(CrystalType.class); } _crystalTypes.add(type); } - public List getCrystalTypes() + public Set getCrystalTypes() { - return _crystalTypes != null ? _crystalTypes : Collections.emptyList(); + return _crystalTypes != null ? _crystalTypes : Collections.emptySet(); } public void addTargetType(AppearanceTargetType type) { if (_targetTypes == null) { - _targetTypes = new ArrayList<>(); + _targetTypes = EnumSet.noneOf(AppearanceTargetType.class); } _targetTypes.add(type); } - public List getTargetTypes() + public Set getTargetTypes() { - return _targetTypes != null ? _targetTypes : Collections.emptyList(); + return _targetTypes != null ? _targetTypes : Collections.emptySet(); } public void addBodyPart(Integer part) { if (_bodyParts == null) { - _bodyParts = new ArrayList<>(); + _bodyParts = new HashSet<>(); } _bodyParts.add(part); } @@ -209,47 +210,47 @@ public class AppearanceStone { if (_allVisualIds == null) { - _allVisualIds = new ArrayList<>(); + _allVisualIds = new HashSet<>(); } _allVisualIds.add(appearanceHolder); } - public List getVisualIds() + public Set getVisualIds() { - return _allVisualIds != null ? _allVisualIds : Collections.emptyList(); + return _allVisualIds != null ? _allVisualIds : Collections.emptySet(); } - public List getBodyParts() + public Set getBodyParts() { - return _bodyParts != null ? _bodyParts : Collections.emptyList(); + return _bodyParts != null ? _bodyParts : Collections.emptySet(); } public void addRace(Race race) { if (_races == null) { - _races = new ArrayList<>(); + _races = EnumSet.noneOf(Race.class); } _races.add(race); } - public List getRaces() + public Set getRaces() { - return _races != null ? _races : Collections.emptyList(); + return _races != null ? _races : Collections.emptySet(); } public void addRaceNot(Race race) { if (_racesNot == null) { - _racesNot = new ArrayList<>(); + _racesNot = EnumSet.noneOf(Race.class); } _racesNot.add(race); } - public List getRacesNot() + public Set getRacesNot() { - return _racesNot != null ? _racesNot : Collections.emptyList(); + return _racesNot != null ? _racesNot : Collections.emptySet(); } /** @@ -302,7 +303,7 @@ public class AppearanceStone { // Seems like in retail item with already changed appearance, can be changed again without being restored. - final AppearanceTargetType targetType = getTargetTypes().get(0); + final AppearanceTargetType targetType = getTargetTypes().stream().findFirst().get(); switch (targetType) { case NONE: diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java index 5d3a79d524..5e067a67e5 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java @@ -16,16 +16,16 @@ */ package org.l2jmobius.gameserver.model.item.enchant; +import java.util.EnumSet; +import java.util.Set; import java.util.logging.Logger; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.item.ItemTemplate; import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.model.item.type.CrystalType; import org.l2jmobius.gameserver.model.item.type.EtcItemType; -import org.l2jmobius.gameserver.model.item.type.ItemType; /** * @author UnAfraid @@ -34,26 +34,27 @@ public abstract class AbstractEnchantItem { protected static final Logger LOGGER = Logger.getLogger(AbstractEnchantItem.class.getName()); - private static final ItemType[] ENCHANT_TYPES = new ItemType[] + private static final Set ENCHANT_TYPES = EnumSet.noneOf(EtcItemType.class); + static { - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM, - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP, - EtcItemType.BLESS_ENCHT_AM, - EtcItemType.BLESS_ENCHT_AM_DOWN, - EtcItemType.BLESS_ENCHT_WP, - EtcItemType.ENCHT_AM, - EtcItemType.ENCHT_WP, - EtcItemType.GIANT_ENCHT_AM, - EtcItemType.GIANT_ENCHT_WP, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - }; + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + } private final int _id; private final CrystalType _grade; @@ -71,7 +72,7 @@ public abstract class AbstractEnchantItem { throw new NullPointerException(); } - else if (!CommonUtil.contains(ENCHANT_TYPES, getItem().getItemType())) + else if (!ENCHANT_TYPES.contains(getItem().getItemType())) { throw new IllegalAccessError(); } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java index 5ba6755084..18508d0145 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java @@ -24,8 +24,10 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Set; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -184,7 +186,7 @@ public class LongTimeEvent extends Quest final Node maxLevelNode = d.getAttributes().getNamedItem("maxLevel"); final int maxLevel = maxLevelNode == null ? Integer.MAX_VALUE : Integer.parseInt(maxLevelNode.getNodeValue()); final Node monsterIdsNode = d.getAttributes().getNamedItem("monsterIds"); - final List monsterIds = new ArrayList<>(); + final Set monsterIds = new HashSet<>(); if (monsterIdsNode != null) { for (String id : monsterIdsNode.getNodeValue().split(",")) diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/residences/ClanHall.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/residences/ClanHall.java index 0c0a529077..fcc850371b 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/residences/ClanHall.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/residences/ClanHall.java @@ -23,7 +23,9 @@ import java.sql.SQLException; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -61,9 +63,9 @@ public class ClanHall extends AbstractResidence private final int _minBid; final int _lease; private final int _deposit; - private final List _npcs; - private final List _doors; - private final List _teleports; + private final Set _npcs = new HashSet<>(); + private final Set _doors = new HashSet<>(); + private final Set _teleports = new HashSet<>(); private final Location _ownerLocation; private final Location _banishLocation; // Dynamic parameters @@ -85,9 +87,21 @@ public class ClanHall extends AbstractResidence _minBid = params.getInt("minBid"); _lease = params.getInt("lease"); _deposit = params.getInt("deposit"); - _npcs = params.getList("npcList", Integer.class); - _doors = params.getList("doorList", Door.class); - _teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + final List npcs = params.getList("npcList", Integer.class); + if (npcs != null) + { + _npcs.addAll(npcs); + } + final List doors = params.getList("doorList", Door.class); + if (doors != null) + { + _doors.addAll(doors); + } + final List teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + if (teleports != null) + { + _teleports.addAll(teleports); + } _ownerLocation = params.getLocation("owner_loc"); _banishLocation = params.getLocation("banish_loc"); // Set dynamic parameters (from DB) @@ -196,7 +210,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Door} related to this {@link ClanHall}. * @return all {@link Door} related to this {@link ClanHall} */ - public List getDoors() + public Set getDoors() { return _doors; } @@ -205,7 +219,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Npc} related to this {@link ClanHall}. * @return all {@link Npc} related to this {@link ClanHall} */ - public List getNpcs() + public Set getNpcs() { return _npcs; } @@ -324,7 +338,7 @@ public class ClanHall extends AbstractResidence return _banishLocation; } - public List getTeleportList() + public Set getTeleportList() { return _teleports; } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/siege/Castle.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/siege/Castle.java index d053196bec..4e90413baf 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/siege/Castle.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/siege/Castle.java @@ -21,8 +21,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.Calendar; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -83,7 +85,7 @@ public class Castle extends AbstractResidence private SiegeZone _zone = null; private ResidenceTeleportZone _teleZone; private Clan _formerOwner = null; - private final List _artefacts = new ArrayList<>(1); + private final Set _artefacts = new HashSet<>(1); private final Map _function = new ConcurrentHashMap<>(); private int _ticketBuyCount = 0; private boolean _isFirstMidVictory = false; @@ -1072,7 +1074,7 @@ public class Castle extends AbstractResidence _artefacts.add(artefact); } - public List getArtefacts() + public Set getArtefacts() { return _artefacts; } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java index 0c79677eae..4ebf954ee5 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.network.serverpackets; -import java.util.List; +import java.util.Set; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.gameserver.data.sql.CharNameTable; @@ -27,19 +27,19 @@ import org.l2jmobius.gameserver.network.OutgoingPackets; */ public class BlockListPacket implements IClientOutgoingPacket { - private final List _playersId; + private final Set _playerIds; - public BlockListPacket(List playersId) + public BlockListPacket(Set playerIds) { - _playersId = playersId; + _playerIds = playerIds; } @Override public boolean write(PacketWriter packet) { OutgoingPackets.BLOCK_LIST.writeId(packet); - packet.writeD(_playersId.size()); - for (int playerId : _playersId) + packet.writeD(_playerIds.size()); + for (int playerId : _playerIds) { packet.writeS(CharNameTable.getInstance().getNameById(playerId)); packet.writeS(""); // memo ? diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java index 8555bb6e86..eb5bfd05d8 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.network.serverpackets; import java.util.List; import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; import org.l2jmobius.commons.network.PacketWriter; @@ -37,7 +38,7 @@ public class ExAcquireSkillInfo implements IClientOutgoingPacket private final int _dualClassLevel; private final long _spCost; private final int _minLevel; - private final List _itemReq; + private final Set _itemReq; private final List _skillRem; /** diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java index 84b5fead76..a163a85735 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java @@ -35,7 +35,7 @@ public class ExChooseShapeShiftingItem implements IClientOutgoingPacket public ExChooseShapeShiftingItem(AppearanceStone stone) { _type = stone.getType(); - _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().get(0); + _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().stream().findFirst().get(); _itemId = stone.getId(); } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/DocumentBase.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/DocumentBase.java index 8a8e13d940..c22140b9c4 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/DocumentBase.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/DocumentBase.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.util; import java.io.File; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -390,12 +391,12 @@ public abstract class DocumentBase case "races": { final String[] racesVal = a.getNodeValue().split(","); - final Race[] races = new Race[racesVal.length]; + final Set races = EnumSet.noneOf(Race.class); for (int r = 0; r < racesVal.length; r++) { if (racesVal[r] != null) { - races[r] = Race.valueOf(racesVal[r]); + races.add(Race.valueOf(racesVal[r])); } } cond = joinAnd(cond, new ConditionPlayerRace(races)); @@ -671,13 +672,13 @@ public abstract class DocumentBase case "instanceid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final ArrayList array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInstanceId(array)); + cond = joinAnd(cond, new ConditionPlayerInstanceId(set)); break; } case "agathionid": @@ -728,10 +729,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -745,10 +746,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -834,13 +835,13 @@ public abstract class DocumentBase case "insidezoneid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInsideZoneId(array)); + cond = joinAnd(cond, new ConditionPlayerInsideZoneId(set)); break; } case "checkabnormal": @@ -961,13 +962,13 @@ public abstract class DocumentBase case "class_id_restriction": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetClassIdRestriction(array)); + cond = joinAnd(cond, new ConditionTargetClassIdRestriction(set)); break; } case "active_effect_id": @@ -1045,13 +1046,13 @@ public abstract class DocumentBase case "npcid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetNpcId(array)); + cond = joinAnd(cond, new ConditionTargetNpcId(set)); break; } case "npctype": diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/bypasshandlers/Link.java b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/bypasshandlers/Link.java index 380a9f1ae3..93bc7f3647 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/bypasshandlers/Link.java +++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/bypasshandlers/Link.java @@ -16,7 +16,9 @@ */ package handlers.bypasshandlers; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.HashSet; +import java.util.Set; + import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.handler.IBypassHandler; import org.l2jmobius.gameserver.model.actor.Creature; @@ -31,37 +33,38 @@ public class Link implements IBypassHandler "Link" }; - private static final String[] VALID_LINKS = + private static final Set VALID_LINKS = new HashSet<>(); + static { - "common/craft_01.htm", - "common/craft_02.htm", - "common/runes_01.htm", - "common/sealed_runes_01.htm", - "common/sealed_runes_02.htm", - "common/sealed_runes_03.htm", - "common/sealed_runes_04.htm", - "common/sealed_runes_05.htm", - "common/sealed_runes_06.htm", - "common/sealed_runes_07.htm", - "common/sealed_runes_08.htm", - "common/sealed_runes_09.htm", - "common/skill_enchant_help_01.htm", - "common/skill_enchant_help_02.htm", - "common/skill_enchant_help_03.htm", - "default/BlessingOfProtection.htm", - "default/SupportMagic.htm", - "fisherman/fishing_manual001.htm", - "fisherman/fishing_manual002.htm", - "fisherman/fishing_manual003.htm", - "fisherman/fishing_manual004.htm", - "fisherman/fishing_manual005.htm", - "fortress/foreman.htm", - "petmanager/evolve.htm", - "petmanager/exchange.htm", - "petmanager/instructions.htm", - "warehouse/clanwh.htm", - "warehouse/privatewh.htm", - }; + VALID_LINKS.add("common/craft_01.htm"); + VALID_LINKS.add("common/craft_02.htm"); + VALID_LINKS.add("common/runes_01.htm"); + VALID_LINKS.add("common/runes_01.htm"); + VALID_LINKS.add("common/sealed_runes_02.htm"); + VALID_LINKS.add("common/sealed_runes_03.htm"); + VALID_LINKS.add("common/sealed_runes_04.htm"); + VALID_LINKS.add("common/sealed_runes_05.htm"); + VALID_LINKS.add("common/sealed_runes_06.htm"); + VALID_LINKS.add("common/sealed_runes_07.htm"); + VALID_LINKS.add("common/sealed_runes_08.htm"); + VALID_LINKS.add("common/sealed_runes_09.htm"); + VALID_LINKS.add("common/skill_enchant_help_01.htm"); + VALID_LINKS.add("common/skill_enchant_help_02.htm"); + VALID_LINKS.add("common/skill_enchant_help_03.htm"); + VALID_LINKS.add("default/BlessingOfProtection.htm"); + VALID_LINKS.add("default/SupportMagic.htm"); + VALID_LINKS.add("fisherman/fishing_manual001.htm"); + VALID_LINKS.add("fisherman/fishing_manual002.htm"); + VALID_LINKS.add("fisherman/fishing_manual003.htm"); + VALID_LINKS.add("fisherman/fishing_manual004.htm"); + VALID_LINKS.add("fisherman/fishing_manual008.htm"); + VALID_LINKS.add("fortress/foreman.htm"); + VALID_LINKS.add("petmanager/evolve.htm"); + VALID_LINKS.add("petmanager/exchange.htm"); + VALID_LINKS.add("petmanager/instructions.htm"); + VALID_LINKS.add("warehouse/clanwh.htm"); + VALID_LINKS.add("warehouse/privatewh.htm"); + } @Override public boolean useBypass(String command, Player player, Creature target) @@ -79,12 +82,13 @@ public class Link implements IBypassHandler return false; } - String content = CommonUtil.contains(VALID_LINKS, htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; + String content = VALID_LINKS.contains(htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; // Precaution. if (htmlPath.startsWith("teleporter/") && !(player.getTarget() instanceof Teleporter)) { content = null; } + final NpcHtmlMessage html = new NpcHtmlMessage(target != null ? target.getObjectId() : 0); if (content != null) { diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/itemhandlers/PetFood.java b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/itemhandlers/PetFood.java index 3c5572d4ec..8b908ea095 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/itemhandlers/PetFood.java +++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/itemhandlers/PetFood.java @@ -17,6 +17,7 @@ package handlers.itemhandlers; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.PetDataTable; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -79,7 +80,7 @@ public class PetFood implements IItemHandler final Player player = activeChar.getActingPlayer(); if (player.isMounted()) { - final List foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); + final Set foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); if (foodIds.contains(item.getId()) && player.destroyItem("Consume", item.getObjectId(), 1, null, false)) { player.broadcastPacket(new MagicSkillUse(player, player, skillId, skillLevel, 0, 0)); diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java index 2ad282f683..99f45fbb41 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java +++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.ClanHallData; import org.l2jmobius.gameserver.model.StatSet; @@ -32,12 +33,12 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpCheckResidenceSkillCondition implements ISkillCondition { - private final List _residencesId; + private final Set _residencesId = new HashSet<>(); private final boolean _isWithin; public OpCheckResidenceSkillCondition(StatSet params) { - _residencesId = params.getList("residencesId", Integer.class); + _residencesId.addAll(params.getList("residencesId", Integer.class)); _isWithin = params.getBoolean("isWithin"); } diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java index fc2934423b..4a8282d988 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java +++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java @@ -16,9 +16,9 @@ */ package handlers.skillconditionhandlers; -import java.util.ArrayList; -import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -28,18 +28,18 @@ import org.l2jmobius.gameserver.model.skill.ISkillCondition; import org.l2jmobius.gameserver.model.skill.Skill; /** - * @author UnAfraid + * @author UnAfraid, Mobius */ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition { - private final List _npcIds = new ArrayList<>(); + private final Set _npcIds = new HashSet<>(); public OpNeedSummonOrPetSkillCondition(StatSet params) { - final List npcIds = params.getList("npcIds", String.class); + final List npcIds = params.getList("npcIds", Integer.class); if (npcIds != null) { - npcIds.stream().map(Integer::valueOf).forEach(_npcIds::add); + _npcIds.addAll(npcIds); } } @@ -47,7 +47,19 @@ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition public boolean canUse(Creature caster, Skill skill, WorldObject target) { final Summon pet = caster.getPet(); - final Collection summons = caster.getServitors().values(); - return ((pet != null) && _npcIds.stream().anyMatch(npcId -> npcId == pet.getId())) || summons.stream().anyMatch(summon -> _npcIds.contains(summon.getId())); + if ((pet != null) && _npcIds.contains(pet.getId())) + { + return true; + } + + for (Summon summon : caster.getServitors().values()) + { + if (_npcIds.contains(summon.getId())) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java index 8541bc62b4..ef81b291d4 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java +++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,11 +30,11 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetDoorSkillCondition implements ISkillCondition { - private final List _doorIds; + private final Set _doorIds = new HashSet<>(); public OpTargetDoorSkillCondition(StatSet params) { - _doorIds = params.getList("doorIds", Integer.class); + _doorIds.addAll(params.getList("doorIds", Integer.class)); } @Override diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java index 3ce4145703..0ccd571e19 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java +++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,17 +30,17 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetNpcSkillCondition implements ISkillCondition { - private final List _npcId; + private final Set _npcIds = new HashSet<>(); public OpTargetNpcSkillCondition(StatSet params) { - _npcId = params.getList("npcIds", Integer.class); + _npcIds.addAll(params.getList("npcIds", Integer.class)); } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget(); - return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId()); + return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcIds.contains(actualTarget.getId()); } } diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/instances/AbstractInstance.java b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/instances/AbstractInstance.java index 94c337f0df..a5b4ef238a 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/instances/AbstractInstance.java +++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/instances/AbstractInstance.java @@ -16,9 +16,10 @@ */ package instances; +import java.util.HashSet; import java.util.List; +import java.util.Set; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.enums.InstanceReenterType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.instancemanager.InstanceManager; @@ -40,25 +41,29 @@ import ai.AbstractNpcAI; */ public abstract class AbstractInstance extends AbstractNpcAI { - private final int[] _templateIds; + private final Set _templateIds = new HashSet<>(); - public AbstractInstance(int... templateId) + public AbstractInstance(int... templateIds) { - if (templateId.length == 0) + if (templateIds.length == 0) { throw new IllegalStateException("No template ids were provided!"); } - _templateIds = templateId; + + for (int templateId : templateIds) + { + _templateIds.add(templateId); + } } - public int[] getTemplateId() + public Set getTemplateId() { return _templateIds; } public boolean isInInstance(Instance instance) { - return (instance != null) && CommonUtil.contains(_templateIds, instance.getTemplateId()); + return (instance != null) && _templateIds.contains(instance.getTemplateId()); } /** diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/Config.java index b6cb0dd517..5fc621eded 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/Config.java @@ -286,7 +286,7 @@ public class Config public static boolean AUTO_LOOT_SLOT_LIMIT; public static int LOOT_RAIDS_PRIVILEGE_INTERVAL; public static int LOOT_RAIDS_PRIVILEGE_CC_SIZE; - public static List AUTO_LOOT_ITEM_IDS; + public static Set AUTO_LOOT_ITEM_IDS; public static boolean ENABLE_KEYBOARD_MOVEMENT; public static int UNSTUCK_INTERVAL; public static int TELEPORT_WATCHDOG_TIMEOUT; @@ -476,7 +476,7 @@ public class Config public static boolean ALLOW_DISCARDITEM; public static int AUTODESTROY_ITEM_AFTER; public static int HERB_AUTO_DESTROY_TIME; - public static List LIST_PROTECTED_ITEMS; + public static Set LIST_PROTECTED_ITEMS; public static boolean DATABASE_CLEAN_UP; public static int CHAR_DATA_STORE_INTERVAL; public static int CLAN_VARIABLES_STORE_INTERVAL; @@ -567,7 +567,7 @@ public class Config public static boolean ALT_OLY_LOG_FIGHTS; public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS; public static boolean ALT_OLY_ANNOUNCE_GAMES; - public static List LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(); + public static Set LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(); public static int ALT_OLY_WEAPON_ENCHANT_LIMIT; public static int ALT_OLY_ARMOR_ENCHANT_LIMIT; public static int ALT_OLY_WAIT_TIME; @@ -1160,9 +1160,9 @@ public class Config public static int AUTO_CP_PERCENTAGE; public static int AUTO_HP_PERCENTAGE; public static int AUTO_MP_PERCENTAGE; - public static List AUTO_CP_ITEM_IDS; - public static List AUTO_HP_ITEM_IDS; - public static List AUTO_MP_ITEM_IDS; + public static Set AUTO_CP_ITEM_IDS; + public static Set AUTO_HP_ITEM_IDS; + public static Set AUTO_MP_ITEM_IDS; public static boolean CUSTOM_STARTING_LOC; public static int CUSTOM_STARTING_LOC_X; public static int CUSTOM_STARTING_LOC_Y; @@ -1172,7 +1172,7 @@ public class Config public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; public static int MOB_MIN_SPAWN_RANGE; public static int MOB_MAX_SPAWN_RANGE; - public static List MOBS_LIST_NOT_RANDOM; + public static Set MOBS_LIST_NOT_RANDOM; public static boolean FREE_JUMPS_FOR_ALL; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; @@ -1191,7 +1191,7 @@ public class Config public static boolean COMMUNITY_PREMIUM_SYSTEM_ENABLED; public static int COMMUNITY_PREMIUM_COIN_ID; public static int COMMUNITY_PREMIUM_PRICE_PER_DAY; - public static List COMMUNITY_AVAILABLE_BUFFS; + public static Set COMMUNITY_AVAILABLE_BUFFS; public static Map COMMUNITY_AVAILABLE_TELEPORTS; public static boolean CUSTOM_DEPOSITABLE_ENABLED; public static boolean CUSTOM_DEPOSITABLE_QUEST_ITEMS; @@ -1839,7 +1839,7 @@ public class Config LOOT_RAIDS_PRIVILEGE_INTERVAL = characterConfig.getInt("RaidLootRightsInterval", 900) * 1000; LOOT_RAIDS_PRIVILEGE_CC_SIZE = characterConfig.getInt("RaidLootRightsCCSize", 45); final String[] autoLootItemIds = characterConfig.getString("AutoLootItemIds", "0").split(","); - AUTO_LOOT_ITEM_IDS = new ArrayList<>(autoLootItemIds.length); + AUTO_LOOT_ITEM_IDS = new HashSet<>(autoLootItemIds.length); for (String item : autoLootItemIds) { Integer itm = 0; @@ -1959,7 +1959,7 @@ public class Config AUTODESTROY_ITEM_AFTER = generalConfig.getInt("AutoDestroyDroppedItemAfter", 600); HERB_AUTO_DESTROY_TIME = generalConfig.getInt("AutoDestroyHerbTime", 60) * 1000; final String[] split = generalConfig.getString("ListOfProtectedItems", "0").split(","); - LIST_PROTECTED_ITEMS = new ArrayList<>(split.length); + LIST_PROTECTED_ITEMS = new HashSet<>(split.length); for (String id : split) { LIST_PROTECTED_ITEMS.add(Integer.parseInt(id)); @@ -2353,7 +2353,7 @@ public class Config if (!olyRestrictedItems.isEmpty()) { final String[] olyRestrictedItemsSplit = olyRestrictedItems.split(","); - LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(olyRestrictedItemsSplit.length); + LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(olyRestrictedItemsSplit.length); for (String id : olyRestrictedItemsSplit) { LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id)); @@ -2467,17 +2467,17 @@ public class Config AUTO_CP_PERCENTAGE = autoPotionsConfig.getInt("AutoCpPercentage", 70); AUTO_HP_PERCENTAGE = autoPotionsConfig.getInt("AutoHpPercentage", 70); AUTO_MP_PERCENTAGE = autoPotionsConfig.getInt("AutoMpPercentage", 70); - AUTO_CP_ITEM_IDS = new ArrayList<>(); + AUTO_CP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoCpItemIds", "0").split(",")) { AUTO_CP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_HP_ITEM_IDS = new ArrayList<>(); + AUTO_HP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoHpItemIds", "0").split(",")) { AUTO_HP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_MP_ITEM_IDS = new ArrayList<>(); + AUTO_MP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoMpItemIds", "0").split(",")) { AUTO_MP_ITEM_IDS.add(Integer.parseInt(s)); @@ -3087,7 +3087,7 @@ public class Config COMMUNITY_PREMIUM_COIN_ID = communityBoardConfig.getInt("CommunityPremiumBuyCoinId", 57); COMMUNITY_PREMIUM_PRICE_PER_DAY = communityBoardConfig.getInt("CommunityPremiumPricePerDay", 1000000); final String[] allowedBuffs = communityBoardConfig.getString("CommunityAvailableBuffs", "").split(","); - COMMUNITY_AVAILABLE_BUFFS = new ArrayList<>(allowedBuffs.length); + COMMUNITY_AVAILABLE_BUFFS = new HashSet<>(allowedBuffs.length); for (String s : allowedBuffs) { COMMUNITY_AVAILABLE_BUFFS.add(Integer.parseInt(s)); @@ -3407,7 +3407,7 @@ public class Config if (ENABLE_RANDOM_MONSTER_SPAWNS) { final String[] mobsIds = randomSpawnsConfig.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); - MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + MOBS_LIST_NOT_RANDOM = new HashSet<>(mobsIds.length); for (String id : mobsIds) { MOBS_LIST_NOT_RANDOM.add(Integer.parseInt(id)); diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java index d6e0183c6f..c3977185b4 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java @@ -202,8 +202,7 @@ public class ClanHallData implements IXmlReader final Door door = DoorData.getInstance().getDoor(doorId); for (ClanHall ch : _clanHalls.values()) { - final List doors = ch.getDoors(); - if ((doors != null) && doors.contains(door)) + if (ch.getDoors().contains(door)) { return ch; } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java index 6aa0a1fdde..fb395b9e2d 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java @@ -17,10 +17,10 @@ package org.l2jmobius.gameserver.data.xml; import java.io.File; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -42,7 +42,7 @@ public class FakePlayerData implements IXmlReader private final Map _fakePlayerInfos = new HashMap<>(); private final Map _fakePlayerNames = new HashMap<>(); private final Map _fakePlayerIds = new HashMap<>(); - private final List _talkableFakePlayerNames = new ArrayList<>(); + private final Set _talkableFakePlayerNames = new HashSet<>(); protected FakePlayerData() { diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java index d335b95954..1122d7b9ba 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java @@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -49,7 +51,7 @@ import org.l2jmobius.gameserver.util.Util; public class SellBuffsManager implements IXmlReader { private static final Logger LOGGER = Logger.getLogger(SellBuffsManager.class.getName()); - private static final List ALLOWED_BUFFS = new ArrayList<>(); + private static final Set ALLOWED_BUFFS = new HashSet<>(); private static final String HTML_FOLDER = "data/html/mods/SellBuffs/"; protected SellBuffsManager() @@ -76,11 +78,7 @@ public class SellBuffsManager implements IXmlReader { final Element elem = (Element) node.item(i); final int skillId = Integer.parseInt(elem.getAttribute("id")); - - if (!ALLOWED_BUFFS.contains(skillId)) - { - ALLOWED_BUFFS.add(skillId); - } + ALLOWED_BUFFS.add(skillId); } } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java index b10f75ef3d..1e45a21319 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java @@ -19,8 +19,10 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; @@ -67,7 +69,7 @@ public class WalkingManager implements IXmlReader public static final byte REPEAT_TELE_FIRST = 2; public static final byte REPEAT_RANDOM = 3; - private final List _targetedNpcIds = new ArrayList<>(); + private final Set _targetedNpcIds = new HashSet<>(); private final Map _routes = new HashMap<>(); // all available routes private final Map _activeRoutes = new HashMap<>(); // each record represents NPC, moving by predefined route from _routes, and moving progress private final Map _routesToAttach = new HashMap<>(); // each record represents NPC and all available routes for it diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/BlockList.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/BlockList.java index 1af9941ed5..9ac6266e22 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/BlockList.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/BlockList.java @@ -19,9 +19,9 @@ package org.l2jmobius.gameserver.model; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -36,10 +36,11 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; public class BlockList { private static final Logger LOGGER = Logger.getLogger(BlockList.class.getName()); - private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); + + private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); private final Player _owner; - private List _blockList; + private Set _blockList; public BlockList(Player owner) { @@ -68,9 +69,9 @@ public class BlockList OFFLINE_LIST.put(_owner.getObjectId(), _blockList); } - private static List loadList(int objId) + private static Set loadList(int objId) { - final List list = new ArrayList<>(); + final Set list = new HashSet<>(); try (Connection con = DatabaseFactory.getConnection(); PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1")) { @@ -158,7 +159,7 @@ public class BlockList _owner.setMessageRefusal(value); } - private List getBlockList() + private Set getBlockList() { return _blockList; } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/PetData.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/PetData.java index b534c21f36..231b85e85f 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/PetData.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/PetData.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; import org.l2jmobius.gameserver.model.holders.SkillHolder; @@ -40,7 +42,7 @@ public class PetData private int _minLevel = Byte.MAX_VALUE; private int _maxLevel = 0; private boolean _syncLevel = false; - private final List _food = new ArrayList<>(); + private final Set _food = new HashSet<>(); public PetData(int npcId, int itemId) { @@ -133,7 +135,7 @@ public class PetData /** * @return the pet's food list. */ - public List getFood() + public Set getFood() { return _food; } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/SkillLearn.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/SkillLearn.java index a69d30f105..3d5704b5f2 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/SkillLearn.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/SkillLearn.java @@ -16,9 +16,8 @@ */ package org.l2jmobius.gameserver.model; -import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashSet; -import java.util.List; import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -40,12 +39,12 @@ public class SkillLearn private final int _getDualClassLevel; private final boolean _autoGet; private final long _levelUpSp; - private final List _requiredItems = new ArrayList<>(); - private final List _races = new ArrayList<>(); - private final List _preReqSkills = new ArrayList<>(); + private final Set _requiredItems = new HashSet<>(1); + private final Set _races = EnumSet.noneOf(Race.class); + private final Set _preReqSkills = new HashSet<>(1); private SocialClass _socialClass; private final boolean _residenceSkill; - private final List _residenceIds = new ArrayList<>(); + private final Set _residenceIds = new HashSet<>(1); private final boolean _learnedByNpc; private final boolean _learnedByFS; private final Set _removeSkills = new HashSet<>(1); @@ -133,9 +132,9 @@ public class SkillLearn } /** - * @return the list with the item holders required to acquire this skill. + * @return the set with the item holders required to acquire this skill. */ - public List getRequiredItems() + public Set getRequiredItems() { return _requiredItems; } @@ -150,9 +149,9 @@ public class SkillLearn } /** - * @return a list with the races that can acquire this skill. + * @return a set with the races that can acquire this skill. */ - public List getRaces() + public Set getRaces() { return _races; } @@ -167,9 +166,9 @@ public class SkillLearn } /** - * @return the list of skill holders required to acquire this skill. + * @return the set of skill holders required to acquire this skill. */ - public List getPreReqSkills() + public Set getPreReqSkills() { return _preReqSkills; } @@ -212,9 +211,9 @@ public class SkillLearn } /** - * @return a list with the Ids where this skill is available. + * @return a set with the Ids where this skill is available. */ - public List getResidenceIds() + public Set getResidenceIds() { return _residenceIds; } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java index 76d810a2d9..3b04eafa72 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java @@ -22,7 +22,6 @@ import java.sql.ResultSet; import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.List; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; @@ -153,7 +152,7 @@ public class Pet extends Summon broadcastStatusUpdate(); - final List foodIds = getPetData().getFood(); + final Set foodIds = getPetData().getFood(); if (foodIds.isEmpty()) { if (isUncontrollable()) diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java index 11efe435d8..1ed0ee81a4 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java @@ -16,8 +16,8 @@ */ package org.l2jmobius.gameserver.model.actor.instance; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import org.l2jmobius.commons.threads.ThreadPool; @@ -57,7 +57,7 @@ public class Trap extends Npc private boolean _isTriggered; private final int _lifeTime; private Player _owner; - private final List _playersWhoDetectedMe = new ArrayList<>(); + private final Set _playersWhoDetectedMe = new HashSet<>(); private final SkillHolder _skill; private int _remainingTime; // Tasks diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java index 71ef076212..3ba8c20a9b 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor.tasks.player; -import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -69,11 +69,12 @@ public class PetFeedTask implements Runnable _player.sendPacket(SystemMessageId.YOU_ARE_OUT_OF_FEED_MOUNT_STATUS_CANCELED); } - final List foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); + final Set foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); if (foodIds.isEmpty()) { return; } + Item food = null; for (int id : foodIds) { diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java index 50d2a821c3..2611b5f121 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.actor.Creature; @@ -29,9 +29,9 @@ import org.l2jmobius.gameserver.model.zone.ZoneType; */ public class ConditionPlayerInsideZoneId extends Condition { - private final List _zones; + private final Set _zones; - public ConditionPlayerInsideZoneId(List zones) + public ConditionPlayerInsideZoneId(Set zones) { _zones = zones; } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java index c15065eca2..d644f663f5 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Player; @@ -29,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerInstanceId extends Condition { - private final List _instanceIds; + private final Set _instanceIds; /** * Instantiates a new condition player instance id. * @param instanceIds the instance ids */ - public ConditionPlayerInstanceId(List instanceIds) + public ConditionPlayerInstanceId(Set instanceIds) { _instanceIds = instanceIds; } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java index 14d61089ed..7c375ec45e 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -28,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerRace extends Condition { - private final Race[] _races; + private final Set _races; /** * Instantiates a new condition player race. * @param races the list containing the allowed races. */ - public ConditionPlayerRace(Race[] races) + public ConditionPlayerRace(Set races) { _races = races; } @@ -46,6 +47,6 @@ public class ConditionPlayerRace extends Condition { return false; } - return CommonUtil.contains(_races, effector.getActingPlayer().getRace()); + return _races.contains(effector.getActingPlayer().getRace()); } } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java index 0f54766571..0b326e3f40 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId())) + if (_npcIds.contains(target.getId())) { existNpc = true; break; diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java index c5c9b5ff0e..db64b6bd7b 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromSummonedNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromSummonedNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromSummonedNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromSummonedNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId()) && (effector == target.getSummoner())) + if (_npcIds.contains(target.getId()) && (effector == target.getSummoner())) { existNpc = true; break; diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java index a3fb0f5374..a47b4b4983 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetClassIdRestriction extends Condition { - private final List _classIds; + private final Set _classIds; /** * Instantiates a new condition target class id restriction. * @param classId the class id */ - public ConditionTargetClassIdRestriction(List classId) + public ConditionTargetClassIdRestriction(Set classId) { _classIds = classId; } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java index 82b1bd5877..9bb694f4ef 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetNpcId extends Condition { - private final List _npcIds; + private final Set _npcIds; /** * Instantiates a new condition target npc id. * @param npcIds the npc ids */ - public ConditionTargetNpcId(List npcIds) + public ConditionTargetNpcId(Set npcIds) { _npcIds = npcIds; } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java index f26329bc21..5c86f26ae5 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.holders; -import java.util.Collection; +import java.util.Set; /** * @author Mobius @@ -25,9 +25,9 @@ public class EventDropHolder extends DropHolder { private final int _minLevel; private final int _maxLevel; - private final Collection _monsterIds; + private final Set _monsterIds; - public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Collection monsterIds) + public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Set monsterIds) { super(null, itemId, min, max, chance); _minLevel = minLevel; @@ -45,7 +45,7 @@ public class EventDropHolder extends DropHolder return _maxLevel; } - public Collection getMonsterIds() + public Set getMonsterIds() { return _monsterIds; } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/item/Henna.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/item/Henna.java index 107656dba9..3fa8d06bc6 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/item/Henna.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/item/Henna.java @@ -17,9 +17,11 @@ package org.l2jmobius.gameserver.model.item; import java.util.ArrayList; -import java.util.HashMap; +import java.util.EnumMap; +import java.util.EnumSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.enums.ClassId; import org.l2jmobius.gameserver.model.StatSet; @@ -34,14 +36,14 @@ public class Henna { private final int _dyeId; private final int _dyeItemId; - private final Map _baseStats = new HashMap<>(); + private final Map _baseStats = new EnumMap<>(BaseStat.class); private final int _wearFee; private final int _wearCount; private final int _cancelFee; private final int _cancelCount; private final int _duration; private final List _skills; - private final List _wearClass; + private final Set _wearClass; public Henna(StatSet set) { @@ -59,7 +61,7 @@ public class Henna _cancelCount = set.getInt("cancel_count"); _duration = set.getInt("duration", -1); _skills = new ArrayList<>(); - _wearClass = new ArrayList<>(); + _wearClass = EnumSet.noneOf(ClassId.class); } /** @@ -147,7 +149,7 @@ public class Henna /** * @return the list with the allowed classes to wear this dye. */ - public List getAllowedWearClass() + public Set getAllowedWearClass() { return _wearClass; } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java index d74b1218d3..5d694e5169 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java @@ -17,9 +17,10 @@ package org.l2jmobius.gameserver.model.item.appearance; import java.time.Duration; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.enums.Race; @@ -47,12 +48,12 @@ public class AppearanceStone private final ArmorType _armorType; private final AppearanceHandType _handType; private final AppearanceMagicType _magicType; - private List _crystalTypes; - private List _targetTypes; - private List _bodyParts; - private List _races; - private List _racesNot; - private List _allVisualIds; + private Set _crystalTypes; + private Set _targetTypes; + private Set _bodyParts; + private Set _races; + private Set _racesNot; + private Set _allVisualIds; public AppearanceStone(StatSet set) { @@ -172,35 +173,35 @@ public class AppearanceStone { if (_crystalTypes == null) { - _crystalTypes = new ArrayList<>(); + _crystalTypes = EnumSet.noneOf(CrystalType.class); } _crystalTypes.add(type); } - public List getCrystalTypes() + public Set getCrystalTypes() { - return _crystalTypes != null ? _crystalTypes : Collections.emptyList(); + return _crystalTypes != null ? _crystalTypes : Collections.emptySet(); } public void addTargetType(AppearanceTargetType type) { if (_targetTypes == null) { - _targetTypes = new ArrayList<>(); + _targetTypes = EnumSet.noneOf(AppearanceTargetType.class); } _targetTypes.add(type); } - public List getTargetTypes() + public Set getTargetTypes() { - return _targetTypes != null ? _targetTypes : Collections.emptyList(); + return _targetTypes != null ? _targetTypes : Collections.emptySet(); } public void addBodyPart(long part) { if (_bodyParts == null) { - _bodyParts = new ArrayList<>(); + _bodyParts = new HashSet<>(); } _bodyParts.add(part); } @@ -209,47 +210,47 @@ public class AppearanceStone { if (_allVisualIds == null) { - _allVisualIds = new ArrayList<>(); + _allVisualIds = new HashSet<>(); } _allVisualIds.add(appearanceHolder); } - public List getVisualIds() + public Set getVisualIds() { - return _allVisualIds != null ? _allVisualIds : Collections.emptyList(); + return _allVisualIds != null ? _allVisualIds : Collections.emptySet(); } - public List getBodyParts() + public Set getBodyParts() { - return _bodyParts != null ? _bodyParts : Collections.emptyList(); + return _bodyParts != null ? _bodyParts : Collections.emptySet(); } public void addRace(Race race) { if (_races == null) { - _races = new ArrayList<>(); + _races = EnumSet.noneOf(Race.class); } _races.add(race); } - public List getRaces() + public Set getRaces() { - return _races != null ? _races : Collections.emptyList(); + return _races != null ? _races : Collections.emptySet(); } public void addRaceNot(Race race) { if (_racesNot == null) { - _racesNot = new ArrayList<>(); + _racesNot = EnumSet.noneOf(Race.class); } _racesNot.add(race); } - public List getRacesNot() + public Set getRacesNot() { - return _racesNot != null ? _racesNot : Collections.emptyList(); + return _racesNot != null ? _racesNot : Collections.emptySet(); } /** @@ -302,7 +303,7 @@ public class AppearanceStone { // Seems like in retail item with already changed appearance, can be changed again without being restored. - final AppearanceTargetType targetType = getTargetTypes().get(0); + final AppearanceTargetType targetType = getTargetTypes().stream().findFirst().get(); switch (targetType) { case NONE: diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java index 5d3a79d524..5e067a67e5 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java @@ -16,16 +16,16 @@ */ package org.l2jmobius.gameserver.model.item.enchant; +import java.util.EnumSet; +import java.util.Set; import java.util.logging.Logger; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.item.ItemTemplate; import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.model.item.type.CrystalType; import org.l2jmobius.gameserver.model.item.type.EtcItemType; -import org.l2jmobius.gameserver.model.item.type.ItemType; /** * @author UnAfraid @@ -34,26 +34,27 @@ public abstract class AbstractEnchantItem { protected static final Logger LOGGER = Logger.getLogger(AbstractEnchantItem.class.getName()); - private static final ItemType[] ENCHANT_TYPES = new ItemType[] + private static final Set ENCHANT_TYPES = EnumSet.noneOf(EtcItemType.class); + static { - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM, - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP, - EtcItemType.BLESS_ENCHT_AM, - EtcItemType.BLESS_ENCHT_AM_DOWN, - EtcItemType.BLESS_ENCHT_WP, - EtcItemType.ENCHT_AM, - EtcItemType.ENCHT_WP, - EtcItemType.GIANT_ENCHT_AM, - EtcItemType.GIANT_ENCHT_WP, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - }; + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + } private final int _id; private final CrystalType _grade; @@ -71,7 +72,7 @@ public abstract class AbstractEnchantItem { throw new NullPointerException(); } - else if (!CommonUtil.contains(ENCHANT_TYPES, getItem().getItemType())) + else if (!ENCHANT_TYPES.contains(getItem().getItemType())) { throw new IllegalAccessError(); } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java index 5ba6755084..18508d0145 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java @@ -24,8 +24,10 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Set; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -184,7 +186,7 @@ public class LongTimeEvent extends Quest final Node maxLevelNode = d.getAttributes().getNamedItem("maxLevel"); final int maxLevel = maxLevelNode == null ? Integer.MAX_VALUE : Integer.parseInt(maxLevelNode.getNodeValue()); final Node monsterIdsNode = d.getAttributes().getNamedItem("monsterIds"); - final List monsterIds = new ArrayList<>(); + final Set monsterIds = new HashSet<>(); if (monsterIdsNode != null) { for (String id : monsterIdsNode.getNodeValue().split(",")) diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/residences/ClanHall.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/residences/ClanHall.java index 0c0a529077..fcc850371b 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/residences/ClanHall.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/residences/ClanHall.java @@ -23,7 +23,9 @@ import java.sql.SQLException; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -61,9 +63,9 @@ public class ClanHall extends AbstractResidence private final int _minBid; final int _lease; private final int _deposit; - private final List _npcs; - private final List _doors; - private final List _teleports; + private final Set _npcs = new HashSet<>(); + private final Set _doors = new HashSet<>(); + private final Set _teleports = new HashSet<>(); private final Location _ownerLocation; private final Location _banishLocation; // Dynamic parameters @@ -85,9 +87,21 @@ public class ClanHall extends AbstractResidence _minBid = params.getInt("minBid"); _lease = params.getInt("lease"); _deposit = params.getInt("deposit"); - _npcs = params.getList("npcList", Integer.class); - _doors = params.getList("doorList", Door.class); - _teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + final List npcs = params.getList("npcList", Integer.class); + if (npcs != null) + { + _npcs.addAll(npcs); + } + final List doors = params.getList("doorList", Door.class); + if (doors != null) + { + _doors.addAll(doors); + } + final List teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + if (teleports != null) + { + _teleports.addAll(teleports); + } _ownerLocation = params.getLocation("owner_loc"); _banishLocation = params.getLocation("banish_loc"); // Set dynamic parameters (from DB) @@ -196,7 +210,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Door} related to this {@link ClanHall}. * @return all {@link Door} related to this {@link ClanHall} */ - public List getDoors() + public Set getDoors() { return _doors; } @@ -205,7 +219,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Npc} related to this {@link ClanHall}. * @return all {@link Npc} related to this {@link ClanHall} */ - public List getNpcs() + public Set getNpcs() { return _npcs; } @@ -324,7 +338,7 @@ public class ClanHall extends AbstractResidence return _banishLocation; } - public List getTeleportList() + public Set getTeleportList() { return _teleports; } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/siege/Castle.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/siege/Castle.java index d053196bec..4e90413baf 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/siege/Castle.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/siege/Castle.java @@ -21,8 +21,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.Calendar; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -83,7 +85,7 @@ public class Castle extends AbstractResidence private SiegeZone _zone = null; private ResidenceTeleportZone _teleZone; private Clan _formerOwner = null; - private final List _artefacts = new ArrayList<>(1); + private final Set _artefacts = new HashSet<>(1); private final Map _function = new ConcurrentHashMap<>(); private int _ticketBuyCount = 0; private boolean _isFirstMidVictory = false; @@ -1072,7 +1074,7 @@ public class Castle extends AbstractResidence _artefacts.add(artefact); } - public List getArtefacts() + public Set getArtefacts() { return _artefacts; } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java index 0c79677eae..4ebf954ee5 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.network.serverpackets; -import java.util.List; +import java.util.Set; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.gameserver.data.sql.CharNameTable; @@ -27,19 +27,19 @@ import org.l2jmobius.gameserver.network.OutgoingPackets; */ public class BlockListPacket implements IClientOutgoingPacket { - private final List _playersId; + private final Set _playerIds; - public BlockListPacket(List playersId) + public BlockListPacket(Set playerIds) { - _playersId = playersId; + _playerIds = playerIds; } @Override public boolean write(PacketWriter packet) { OutgoingPackets.BLOCK_LIST.writeId(packet); - packet.writeD(_playersId.size()); - for (int playerId : _playersId) + packet.writeD(_playerIds.size()); + for (int playerId : _playerIds) { packet.writeS(CharNameTable.getInstance().getNameById(playerId)); packet.writeS(""); // memo ? diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java index 8555bb6e86..eb5bfd05d8 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.network.serverpackets; import java.util.List; import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; import org.l2jmobius.commons.network.PacketWriter; @@ -37,7 +38,7 @@ public class ExAcquireSkillInfo implements IClientOutgoingPacket private final int _dualClassLevel; private final long _spCost; private final int _minLevel; - private final List _itemReq; + private final Set _itemReq; private final List _skillRem; /** diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java index 84b5fead76..a163a85735 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java @@ -35,7 +35,7 @@ public class ExChooseShapeShiftingItem implements IClientOutgoingPacket public ExChooseShapeShiftingItem(AppearanceStone stone) { _type = stone.getType(); - _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().get(0); + _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().stream().findFirst().get(); _itemId = stone.getId(); } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/DocumentBase.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/DocumentBase.java index 8a8e13d940..c22140b9c4 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/DocumentBase.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/DocumentBase.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.util; import java.io.File; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -390,12 +391,12 @@ public abstract class DocumentBase case "races": { final String[] racesVal = a.getNodeValue().split(","); - final Race[] races = new Race[racesVal.length]; + final Set races = EnumSet.noneOf(Race.class); for (int r = 0; r < racesVal.length; r++) { if (racesVal[r] != null) { - races[r] = Race.valueOf(racesVal[r]); + races.add(Race.valueOf(racesVal[r])); } } cond = joinAnd(cond, new ConditionPlayerRace(races)); @@ -671,13 +672,13 @@ public abstract class DocumentBase case "instanceid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final ArrayList array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInstanceId(array)); + cond = joinAnd(cond, new ConditionPlayerInstanceId(set)); break; } case "agathionid": @@ -728,10 +729,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -745,10 +746,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -834,13 +835,13 @@ public abstract class DocumentBase case "insidezoneid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInsideZoneId(array)); + cond = joinAnd(cond, new ConditionPlayerInsideZoneId(set)); break; } case "checkabnormal": @@ -961,13 +962,13 @@ public abstract class DocumentBase case "class_id_restriction": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetClassIdRestriction(array)); + cond = joinAnd(cond, new ConditionTargetClassIdRestriction(set)); break; } case "active_effect_id": @@ -1045,13 +1046,13 @@ public abstract class DocumentBase case "npcid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetNpcId(array)); + cond = joinAnd(cond, new ConditionTargetNpcId(set)); break; } case "npctype": diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/bypasshandlers/Link.java b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/bypasshandlers/Link.java index 380a9f1ae3..93bc7f3647 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/bypasshandlers/Link.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/bypasshandlers/Link.java @@ -16,7 +16,9 @@ */ package handlers.bypasshandlers; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.HashSet; +import java.util.Set; + import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.handler.IBypassHandler; import org.l2jmobius.gameserver.model.actor.Creature; @@ -31,37 +33,38 @@ public class Link implements IBypassHandler "Link" }; - private static final String[] VALID_LINKS = + private static final Set VALID_LINKS = new HashSet<>(); + static { - "common/craft_01.htm", - "common/craft_02.htm", - "common/runes_01.htm", - "common/sealed_runes_01.htm", - "common/sealed_runes_02.htm", - "common/sealed_runes_03.htm", - "common/sealed_runes_04.htm", - "common/sealed_runes_05.htm", - "common/sealed_runes_06.htm", - "common/sealed_runes_07.htm", - "common/sealed_runes_08.htm", - "common/sealed_runes_09.htm", - "common/skill_enchant_help_01.htm", - "common/skill_enchant_help_02.htm", - "common/skill_enchant_help_03.htm", - "default/BlessingOfProtection.htm", - "default/SupportMagic.htm", - "fisherman/fishing_manual001.htm", - "fisherman/fishing_manual002.htm", - "fisherman/fishing_manual003.htm", - "fisherman/fishing_manual004.htm", - "fisherman/fishing_manual005.htm", - "fortress/foreman.htm", - "petmanager/evolve.htm", - "petmanager/exchange.htm", - "petmanager/instructions.htm", - "warehouse/clanwh.htm", - "warehouse/privatewh.htm", - }; + VALID_LINKS.add("common/craft_01.htm"); + VALID_LINKS.add("common/craft_02.htm"); + VALID_LINKS.add("common/runes_01.htm"); + VALID_LINKS.add("common/runes_01.htm"); + VALID_LINKS.add("common/sealed_runes_02.htm"); + VALID_LINKS.add("common/sealed_runes_03.htm"); + VALID_LINKS.add("common/sealed_runes_04.htm"); + VALID_LINKS.add("common/sealed_runes_05.htm"); + VALID_LINKS.add("common/sealed_runes_06.htm"); + VALID_LINKS.add("common/sealed_runes_07.htm"); + VALID_LINKS.add("common/sealed_runes_08.htm"); + VALID_LINKS.add("common/sealed_runes_09.htm"); + VALID_LINKS.add("common/skill_enchant_help_01.htm"); + VALID_LINKS.add("common/skill_enchant_help_02.htm"); + VALID_LINKS.add("common/skill_enchant_help_03.htm"); + VALID_LINKS.add("default/BlessingOfProtection.htm"); + VALID_LINKS.add("default/SupportMagic.htm"); + VALID_LINKS.add("fisherman/fishing_manual001.htm"); + VALID_LINKS.add("fisherman/fishing_manual002.htm"); + VALID_LINKS.add("fisherman/fishing_manual003.htm"); + VALID_LINKS.add("fisherman/fishing_manual004.htm"); + VALID_LINKS.add("fisherman/fishing_manual008.htm"); + VALID_LINKS.add("fortress/foreman.htm"); + VALID_LINKS.add("petmanager/evolve.htm"); + VALID_LINKS.add("petmanager/exchange.htm"); + VALID_LINKS.add("petmanager/instructions.htm"); + VALID_LINKS.add("warehouse/clanwh.htm"); + VALID_LINKS.add("warehouse/privatewh.htm"); + } @Override public boolean useBypass(String command, Player player, Creature target) @@ -79,12 +82,13 @@ public class Link implements IBypassHandler return false; } - String content = CommonUtil.contains(VALID_LINKS, htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; + String content = VALID_LINKS.contains(htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; // Precaution. if (htmlPath.startsWith("teleporter/") && !(player.getTarget() instanceof Teleporter)) { content = null; } + final NpcHtmlMessage html = new NpcHtmlMessage(target != null ? target.getObjectId() : 0); if (content != null) { diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/itemhandlers/PetFood.java b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/itemhandlers/PetFood.java index 3c5572d4ec..8b908ea095 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/itemhandlers/PetFood.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/itemhandlers/PetFood.java @@ -17,6 +17,7 @@ package handlers.itemhandlers; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.PetDataTable; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -79,7 +80,7 @@ public class PetFood implements IItemHandler final Player player = activeChar.getActingPlayer(); if (player.isMounted()) { - final List foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); + final Set foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); if (foodIds.contains(item.getId()) && player.destroyItem("Consume", item.getObjectId(), 1, null, false)) { player.broadcastPacket(new MagicSkillUse(player, player, skillId, skillLevel, 0, 0)); diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java index 2ad282f683..99f45fbb41 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.ClanHallData; import org.l2jmobius.gameserver.model.StatSet; @@ -32,12 +33,12 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpCheckResidenceSkillCondition implements ISkillCondition { - private final List _residencesId; + private final Set _residencesId = new HashSet<>(); private final boolean _isWithin; public OpCheckResidenceSkillCondition(StatSet params) { - _residencesId = params.getList("residencesId", Integer.class); + _residencesId.addAll(params.getList("residencesId", Integer.class)); _isWithin = params.getBoolean("isWithin"); } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java index fc2934423b..4a8282d988 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java @@ -16,9 +16,9 @@ */ package handlers.skillconditionhandlers; -import java.util.ArrayList; -import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -28,18 +28,18 @@ import org.l2jmobius.gameserver.model.skill.ISkillCondition; import org.l2jmobius.gameserver.model.skill.Skill; /** - * @author UnAfraid + * @author UnAfraid, Mobius */ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition { - private final List _npcIds = new ArrayList<>(); + private final Set _npcIds = new HashSet<>(); public OpNeedSummonOrPetSkillCondition(StatSet params) { - final List npcIds = params.getList("npcIds", String.class); + final List npcIds = params.getList("npcIds", Integer.class); if (npcIds != null) { - npcIds.stream().map(Integer::valueOf).forEach(_npcIds::add); + _npcIds.addAll(npcIds); } } @@ -47,7 +47,19 @@ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition public boolean canUse(Creature caster, Skill skill, WorldObject target) { final Summon pet = caster.getPet(); - final Collection summons = caster.getServitors().values(); - return ((pet != null) && _npcIds.stream().anyMatch(npcId -> npcId == pet.getId())) || summons.stream().anyMatch(summon -> _npcIds.contains(summon.getId())); + if ((pet != null) && _npcIds.contains(pet.getId())) + { + return true; + } + + for (Summon summon : caster.getServitors().values()) + { + if (_npcIds.contains(summon.getId())) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java index 8541bc62b4..ef81b291d4 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,11 +30,11 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetDoorSkillCondition implements ISkillCondition { - private final List _doorIds; + private final Set _doorIds = new HashSet<>(); public OpTargetDoorSkillCondition(StatSet params) { - _doorIds = params.getList("doorIds", Integer.class); + _doorIds.addAll(params.getList("doorIds", Integer.class)); } @Override diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java index 3ce4145703..0ccd571e19 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,17 +30,17 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetNpcSkillCondition implements ISkillCondition { - private final List _npcId; + private final Set _npcIds = new HashSet<>(); public OpTargetNpcSkillCondition(StatSet params) { - _npcId = params.getList("npcIds", Integer.class); + _npcIds.addAll(params.getList("npcIds", Integer.class)); } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget(); - return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId()); + return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcIds.contains(actualTarget.getId()); } } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/instances/AbstractInstance.java b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/instances/AbstractInstance.java index 6ba657bc23..07db6ee59d 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/instances/AbstractInstance.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/instances/AbstractInstance.java @@ -16,9 +16,10 @@ */ package instances; +import java.util.HashSet; import java.util.List; +import java.util.Set; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.enums.InstanceReenterType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.instancemanager.InstanceManager; @@ -40,25 +41,29 @@ import ai.AbstractNpcAI; */ public abstract class AbstractInstance extends AbstractNpcAI { - private final int[] _templateIds; + private final Set _templateIds = new HashSet<>(); - public AbstractInstance(int... templateId) + public AbstractInstance(int... templateIds) { - if (templateId.length == 0) + if (templateIds.length == 0) { throw new IllegalStateException("No template ids were provided!"); } - _templateIds = templateId; + + for (int templateId : templateIds) + { + _templateIds.add(templateId); + } } - public int[] getTemplateId() + public Set getTemplateId() { return _templateIds; } public boolean isInInstance(Instance instance) { - return (instance != null) && CommonUtil.contains(_templateIds, instance.getTemplateId()); + return (instance != null) && _templateIds.contains(instance.getTemplateId()); } /** diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/Config.java index b6cb0dd517..5fc621eded 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/Config.java @@ -286,7 +286,7 @@ public class Config public static boolean AUTO_LOOT_SLOT_LIMIT; public static int LOOT_RAIDS_PRIVILEGE_INTERVAL; public static int LOOT_RAIDS_PRIVILEGE_CC_SIZE; - public static List AUTO_LOOT_ITEM_IDS; + public static Set AUTO_LOOT_ITEM_IDS; public static boolean ENABLE_KEYBOARD_MOVEMENT; public static int UNSTUCK_INTERVAL; public static int TELEPORT_WATCHDOG_TIMEOUT; @@ -476,7 +476,7 @@ public class Config public static boolean ALLOW_DISCARDITEM; public static int AUTODESTROY_ITEM_AFTER; public static int HERB_AUTO_DESTROY_TIME; - public static List LIST_PROTECTED_ITEMS; + public static Set LIST_PROTECTED_ITEMS; public static boolean DATABASE_CLEAN_UP; public static int CHAR_DATA_STORE_INTERVAL; public static int CLAN_VARIABLES_STORE_INTERVAL; @@ -567,7 +567,7 @@ public class Config public static boolean ALT_OLY_LOG_FIGHTS; public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS; public static boolean ALT_OLY_ANNOUNCE_GAMES; - public static List LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(); + public static Set LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(); public static int ALT_OLY_WEAPON_ENCHANT_LIMIT; public static int ALT_OLY_ARMOR_ENCHANT_LIMIT; public static int ALT_OLY_WAIT_TIME; @@ -1160,9 +1160,9 @@ public class Config public static int AUTO_CP_PERCENTAGE; public static int AUTO_HP_PERCENTAGE; public static int AUTO_MP_PERCENTAGE; - public static List AUTO_CP_ITEM_IDS; - public static List AUTO_HP_ITEM_IDS; - public static List AUTO_MP_ITEM_IDS; + public static Set AUTO_CP_ITEM_IDS; + public static Set AUTO_HP_ITEM_IDS; + public static Set AUTO_MP_ITEM_IDS; public static boolean CUSTOM_STARTING_LOC; public static int CUSTOM_STARTING_LOC_X; public static int CUSTOM_STARTING_LOC_Y; @@ -1172,7 +1172,7 @@ public class Config public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; public static int MOB_MIN_SPAWN_RANGE; public static int MOB_MAX_SPAWN_RANGE; - public static List MOBS_LIST_NOT_RANDOM; + public static Set MOBS_LIST_NOT_RANDOM; public static boolean FREE_JUMPS_FOR_ALL; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; @@ -1191,7 +1191,7 @@ public class Config public static boolean COMMUNITY_PREMIUM_SYSTEM_ENABLED; public static int COMMUNITY_PREMIUM_COIN_ID; public static int COMMUNITY_PREMIUM_PRICE_PER_DAY; - public static List COMMUNITY_AVAILABLE_BUFFS; + public static Set COMMUNITY_AVAILABLE_BUFFS; public static Map COMMUNITY_AVAILABLE_TELEPORTS; public static boolean CUSTOM_DEPOSITABLE_ENABLED; public static boolean CUSTOM_DEPOSITABLE_QUEST_ITEMS; @@ -1839,7 +1839,7 @@ public class Config LOOT_RAIDS_PRIVILEGE_INTERVAL = characterConfig.getInt("RaidLootRightsInterval", 900) * 1000; LOOT_RAIDS_PRIVILEGE_CC_SIZE = characterConfig.getInt("RaidLootRightsCCSize", 45); final String[] autoLootItemIds = characterConfig.getString("AutoLootItemIds", "0").split(","); - AUTO_LOOT_ITEM_IDS = new ArrayList<>(autoLootItemIds.length); + AUTO_LOOT_ITEM_IDS = new HashSet<>(autoLootItemIds.length); for (String item : autoLootItemIds) { Integer itm = 0; @@ -1959,7 +1959,7 @@ public class Config AUTODESTROY_ITEM_AFTER = generalConfig.getInt("AutoDestroyDroppedItemAfter", 600); HERB_AUTO_DESTROY_TIME = generalConfig.getInt("AutoDestroyHerbTime", 60) * 1000; final String[] split = generalConfig.getString("ListOfProtectedItems", "0").split(","); - LIST_PROTECTED_ITEMS = new ArrayList<>(split.length); + LIST_PROTECTED_ITEMS = new HashSet<>(split.length); for (String id : split) { LIST_PROTECTED_ITEMS.add(Integer.parseInt(id)); @@ -2353,7 +2353,7 @@ public class Config if (!olyRestrictedItems.isEmpty()) { final String[] olyRestrictedItemsSplit = olyRestrictedItems.split(","); - LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(olyRestrictedItemsSplit.length); + LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(olyRestrictedItemsSplit.length); for (String id : olyRestrictedItemsSplit) { LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id)); @@ -2467,17 +2467,17 @@ public class Config AUTO_CP_PERCENTAGE = autoPotionsConfig.getInt("AutoCpPercentage", 70); AUTO_HP_PERCENTAGE = autoPotionsConfig.getInt("AutoHpPercentage", 70); AUTO_MP_PERCENTAGE = autoPotionsConfig.getInt("AutoMpPercentage", 70); - AUTO_CP_ITEM_IDS = new ArrayList<>(); + AUTO_CP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoCpItemIds", "0").split(",")) { AUTO_CP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_HP_ITEM_IDS = new ArrayList<>(); + AUTO_HP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoHpItemIds", "0").split(",")) { AUTO_HP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_MP_ITEM_IDS = new ArrayList<>(); + AUTO_MP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoMpItemIds", "0").split(",")) { AUTO_MP_ITEM_IDS.add(Integer.parseInt(s)); @@ -3087,7 +3087,7 @@ public class Config COMMUNITY_PREMIUM_COIN_ID = communityBoardConfig.getInt("CommunityPremiumBuyCoinId", 57); COMMUNITY_PREMIUM_PRICE_PER_DAY = communityBoardConfig.getInt("CommunityPremiumPricePerDay", 1000000); final String[] allowedBuffs = communityBoardConfig.getString("CommunityAvailableBuffs", "").split(","); - COMMUNITY_AVAILABLE_BUFFS = new ArrayList<>(allowedBuffs.length); + COMMUNITY_AVAILABLE_BUFFS = new HashSet<>(allowedBuffs.length); for (String s : allowedBuffs) { COMMUNITY_AVAILABLE_BUFFS.add(Integer.parseInt(s)); @@ -3407,7 +3407,7 @@ public class Config if (ENABLE_RANDOM_MONSTER_SPAWNS) { final String[] mobsIds = randomSpawnsConfig.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); - MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + MOBS_LIST_NOT_RANDOM = new HashSet<>(mobsIds.length); for (String id : mobsIds) { MOBS_LIST_NOT_RANDOM.add(Integer.parseInt(id)); diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java index d6e0183c6f..c3977185b4 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java @@ -202,8 +202,7 @@ public class ClanHallData implements IXmlReader final Door door = DoorData.getInstance().getDoor(doorId); for (ClanHall ch : _clanHalls.values()) { - final List doors = ch.getDoors(); - if ((doors != null) && doors.contains(door)) + if (ch.getDoors().contains(door)) { return ch; } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java index 6aa0a1fdde..fb395b9e2d 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java @@ -17,10 +17,10 @@ package org.l2jmobius.gameserver.data.xml; import java.io.File; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -42,7 +42,7 @@ public class FakePlayerData implements IXmlReader private final Map _fakePlayerInfos = new HashMap<>(); private final Map _fakePlayerNames = new HashMap<>(); private final Map _fakePlayerIds = new HashMap<>(); - private final List _talkableFakePlayerNames = new ArrayList<>(); + private final Set _talkableFakePlayerNames = new HashSet<>(); protected FakePlayerData() { diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java index d335b95954..1122d7b9ba 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java @@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -49,7 +51,7 @@ import org.l2jmobius.gameserver.util.Util; public class SellBuffsManager implements IXmlReader { private static final Logger LOGGER = Logger.getLogger(SellBuffsManager.class.getName()); - private static final List ALLOWED_BUFFS = new ArrayList<>(); + private static final Set ALLOWED_BUFFS = new HashSet<>(); private static final String HTML_FOLDER = "data/html/mods/SellBuffs/"; protected SellBuffsManager() @@ -76,11 +78,7 @@ public class SellBuffsManager implements IXmlReader { final Element elem = (Element) node.item(i); final int skillId = Integer.parseInt(elem.getAttribute("id")); - - if (!ALLOWED_BUFFS.contains(skillId)) - { - ALLOWED_BUFFS.add(skillId); - } + ALLOWED_BUFFS.add(skillId); } } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java index b10f75ef3d..1e45a21319 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java @@ -19,8 +19,10 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; @@ -67,7 +69,7 @@ public class WalkingManager implements IXmlReader public static final byte REPEAT_TELE_FIRST = 2; public static final byte REPEAT_RANDOM = 3; - private final List _targetedNpcIds = new ArrayList<>(); + private final Set _targetedNpcIds = new HashSet<>(); private final Map _routes = new HashMap<>(); // all available routes private final Map _activeRoutes = new HashMap<>(); // each record represents NPC, moving by predefined route from _routes, and moving progress private final Map _routesToAttach = new HashMap<>(); // each record represents NPC and all available routes for it diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/BlockList.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/BlockList.java index 1af9941ed5..9ac6266e22 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/BlockList.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/BlockList.java @@ -19,9 +19,9 @@ package org.l2jmobius.gameserver.model; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -36,10 +36,11 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; public class BlockList { private static final Logger LOGGER = Logger.getLogger(BlockList.class.getName()); - private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); + + private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); private final Player _owner; - private List _blockList; + private Set _blockList; public BlockList(Player owner) { @@ -68,9 +69,9 @@ public class BlockList OFFLINE_LIST.put(_owner.getObjectId(), _blockList); } - private static List loadList(int objId) + private static Set loadList(int objId) { - final List list = new ArrayList<>(); + final Set list = new HashSet<>(); try (Connection con = DatabaseFactory.getConnection(); PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1")) { @@ -158,7 +159,7 @@ public class BlockList _owner.setMessageRefusal(value); } - private List getBlockList() + private Set getBlockList() { return _blockList; } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/PetData.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/PetData.java index b534c21f36..231b85e85f 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/PetData.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/PetData.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; import org.l2jmobius.gameserver.model.holders.SkillHolder; @@ -40,7 +42,7 @@ public class PetData private int _minLevel = Byte.MAX_VALUE; private int _maxLevel = 0; private boolean _syncLevel = false; - private final List _food = new ArrayList<>(); + private final Set _food = new HashSet<>(); public PetData(int npcId, int itemId) { @@ -133,7 +135,7 @@ public class PetData /** * @return the pet's food list. */ - public List getFood() + public Set getFood() { return _food; } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/SkillLearn.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/SkillLearn.java index a69d30f105..3d5704b5f2 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/SkillLearn.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/SkillLearn.java @@ -16,9 +16,8 @@ */ package org.l2jmobius.gameserver.model; -import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashSet; -import java.util.List; import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -40,12 +39,12 @@ public class SkillLearn private final int _getDualClassLevel; private final boolean _autoGet; private final long _levelUpSp; - private final List _requiredItems = new ArrayList<>(); - private final List _races = new ArrayList<>(); - private final List _preReqSkills = new ArrayList<>(); + private final Set _requiredItems = new HashSet<>(1); + private final Set _races = EnumSet.noneOf(Race.class); + private final Set _preReqSkills = new HashSet<>(1); private SocialClass _socialClass; private final boolean _residenceSkill; - private final List _residenceIds = new ArrayList<>(); + private final Set _residenceIds = new HashSet<>(1); private final boolean _learnedByNpc; private final boolean _learnedByFS; private final Set _removeSkills = new HashSet<>(1); @@ -133,9 +132,9 @@ public class SkillLearn } /** - * @return the list with the item holders required to acquire this skill. + * @return the set with the item holders required to acquire this skill. */ - public List getRequiredItems() + public Set getRequiredItems() { return _requiredItems; } @@ -150,9 +149,9 @@ public class SkillLearn } /** - * @return a list with the races that can acquire this skill. + * @return a set with the races that can acquire this skill. */ - public List getRaces() + public Set getRaces() { return _races; } @@ -167,9 +166,9 @@ public class SkillLearn } /** - * @return the list of skill holders required to acquire this skill. + * @return the set of skill holders required to acquire this skill. */ - public List getPreReqSkills() + public Set getPreReqSkills() { return _preReqSkills; } @@ -212,9 +211,9 @@ public class SkillLearn } /** - * @return a list with the Ids where this skill is available. + * @return a set with the Ids where this skill is available. */ - public List getResidenceIds() + public Set getResidenceIds() { return _residenceIds; } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java index 76d810a2d9..3b04eafa72 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java @@ -22,7 +22,6 @@ import java.sql.ResultSet; import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.List; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; @@ -153,7 +152,7 @@ public class Pet extends Summon broadcastStatusUpdate(); - final List foodIds = getPetData().getFood(); + final Set foodIds = getPetData().getFood(); if (foodIds.isEmpty()) { if (isUncontrollable()) diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java index ddd5c20f5c..650e0257d2 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java @@ -16,8 +16,8 @@ */ package org.l2jmobius.gameserver.model.actor.instance; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import org.l2jmobius.commons.threads.ThreadPool; @@ -57,7 +57,7 @@ public class Trap extends Npc private boolean _isTriggered; private final int _lifeTime; private Player _owner; - private final List _playersWhoDetectedMe = new ArrayList<>(); + private final Set _playersWhoDetectedMe = new HashSet<>(); private final SkillHolder _skill; private int _remainingTime; // Tasks diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java index 71ef076212..3ba8c20a9b 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor.tasks.player; -import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -69,11 +69,12 @@ public class PetFeedTask implements Runnable _player.sendPacket(SystemMessageId.YOU_ARE_OUT_OF_FEED_MOUNT_STATUS_CANCELED); } - final List foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); + final Set foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); if (foodIds.isEmpty()) { return; } + Item food = null; for (int id : foodIds) { diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java index 50d2a821c3..2611b5f121 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.actor.Creature; @@ -29,9 +29,9 @@ import org.l2jmobius.gameserver.model.zone.ZoneType; */ public class ConditionPlayerInsideZoneId extends Condition { - private final List _zones; + private final Set _zones; - public ConditionPlayerInsideZoneId(List zones) + public ConditionPlayerInsideZoneId(Set zones) { _zones = zones; } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java index c15065eca2..d644f663f5 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Player; @@ -29,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerInstanceId extends Condition { - private final List _instanceIds; + private final Set _instanceIds; /** * Instantiates a new condition player instance id. * @param instanceIds the instance ids */ - public ConditionPlayerInstanceId(List instanceIds) + public ConditionPlayerInstanceId(Set instanceIds) { _instanceIds = instanceIds; } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java index 14d61089ed..7c375ec45e 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -28,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerRace extends Condition { - private final Race[] _races; + private final Set _races; /** * Instantiates a new condition player race. * @param races the list containing the allowed races. */ - public ConditionPlayerRace(Race[] races) + public ConditionPlayerRace(Set races) { _races = races; } @@ -46,6 +47,6 @@ public class ConditionPlayerRace extends Condition { return false; } - return CommonUtil.contains(_races, effector.getActingPlayer().getRace()); + return _races.contains(effector.getActingPlayer().getRace()); } } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java index 0f54766571..0b326e3f40 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId())) + if (_npcIds.contains(target.getId())) { existNpc = true; break; diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java index c5c9b5ff0e..db64b6bd7b 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromSummonedNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromSummonedNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromSummonedNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromSummonedNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId()) && (effector == target.getSummoner())) + if (_npcIds.contains(target.getId()) && (effector == target.getSummoner())) { existNpc = true; break; diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java index a3fb0f5374..a47b4b4983 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetClassIdRestriction extends Condition { - private final List _classIds; + private final Set _classIds; /** * Instantiates a new condition target class id restriction. * @param classId the class id */ - public ConditionTargetClassIdRestriction(List classId) + public ConditionTargetClassIdRestriction(Set classId) { _classIds = classId; } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java index 82b1bd5877..9bb694f4ef 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetNpcId extends Condition { - private final List _npcIds; + private final Set _npcIds; /** * Instantiates a new condition target npc id. * @param npcIds the npc ids */ - public ConditionTargetNpcId(List npcIds) + public ConditionTargetNpcId(Set npcIds) { _npcIds = npcIds; } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java index f26329bc21..5c86f26ae5 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.holders; -import java.util.Collection; +import java.util.Set; /** * @author Mobius @@ -25,9 +25,9 @@ public class EventDropHolder extends DropHolder { private final int _minLevel; private final int _maxLevel; - private final Collection _monsterIds; + private final Set _monsterIds; - public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Collection monsterIds) + public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Set monsterIds) { super(null, itemId, min, max, chance); _minLevel = minLevel; @@ -45,7 +45,7 @@ public class EventDropHolder extends DropHolder return _maxLevel; } - public Collection getMonsterIds() + public Set getMonsterIds() { return _monsterIds; } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/item/Henna.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/item/Henna.java index 107656dba9..3fa8d06bc6 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/item/Henna.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/item/Henna.java @@ -17,9 +17,11 @@ package org.l2jmobius.gameserver.model.item; import java.util.ArrayList; -import java.util.HashMap; +import java.util.EnumMap; +import java.util.EnumSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.enums.ClassId; import org.l2jmobius.gameserver.model.StatSet; @@ -34,14 +36,14 @@ public class Henna { private final int _dyeId; private final int _dyeItemId; - private final Map _baseStats = new HashMap<>(); + private final Map _baseStats = new EnumMap<>(BaseStat.class); private final int _wearFee; private final int _wearCount; private final int _cancelFee; private final int _cancelCount; private final int _duration; private final List _skills; - private final List _wearClass; + private final Set _wearClass; public Henna(StatSet set) { @@ -59,7 +61,7 @@ public class Henna _cancelCount = set.getInt("cancel_count"); _duration = set.getInt("duration", -1); _skills = new ArrayList<>(); - _wearClass = new ArrayList<>(); + _wearClass = EnumSet.noneOf(ClassId.class); } /** @@ -147,7 +149,7 @@ public class Henna /** * @return the list with the allowed classes to wear this dye. */ - public List getAllowedWearClass() + public Set getAllowedWearClass() { return _wearClass; } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java index d74b1218d3..5d694e5169 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java @@ -17,9 +17,10 @@ package org.l2jmobius.gameserver.model.item.appearance; import java.time.Duration; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.enums.Race; @@ -47,12 +48,12 @@ public class AppearanceStone private final ArmorType _armorType; private final AppearanceHandType _handType; private final AppearanceMagicType _magicType; - private List _crystalTypes; - private List _targetTypes; - private List _bodyParts; - private List _races; - private List _racesNot; - private List _allVisualIds; + private Set _crystalTypes; + private Set _targetTypes; + private Set _bodyParts; + private Set _races; + private Set _racesNot; + private Set _allVisualIds; public AppearanceStone(StatSet set) { @@ -172,35 +173,35 @@ public class AppearanceStone { if (_crystalTypes == null) { - _crystalTypes = new ArrayList<>(); + _crystalTypes = EnumSet.noneOf(CrystalType.class); } _crystalTypes.add(type); } - public List getCrystalTypes() + public Set getCrystalTypes() { - return _crystalTypes != null ? _crystalTypes : Collections.emptyList(); + return _crystalTypes != null ? _crystalTypes : Collections.emptySet(); } public void addTargetType(AppearanceTargetType type) { if (_targetTypes == null) { - _targetTypes = new ArrayList<>(); + _targetTypes = EnumSet.noneOf(AppearanceTargetType.class); } _targetTypes.add(type); } - public List getTargetTypes() + public Set getTargetTypes() { - return _targetTypes != null ? _targetTypes : Collections.emptyList(); + return _targetTypes != null ? _targetTypes : Collections.emptySet(); } public void addBodyPart(long part) { if (_bodyParts == null) { - _bodyParts = new ArrayList<>(); + _bodyParts = new HashSet<>(); } _bodyParts.add(part); } @@ -209,47 +210,47 @@ public class AppearanceStone { if (_allVisualIds == null) { - _allVisualIds = new ArrayList<>(); + _allVisualIds = new HashSet<>(); } _allVisualIds.add(appearanceHolder); } - public List getVisualIds() + public Set getVisualIds() { - return _allVisualIds != null ? _allVisualIds : Collections.emptyList(); + return _allVisualIds != null ? _allVisualIds : Collections.emptySet(); } - public List getBodyParts() + public Set getBodyParts() { - return _bodyParts != null ? _bodyParts : Collections.emptyList(); + return _bodyParts != null ? _bodyParts : Collections.emptySet(); } public void addRace(Race race) { if (_races == null) { - _races = new ArrayList<>(); + _races = EnumSet.noneOf(Race.class); } _races.add(race); } - public List getRaces() + public Set getRaces() { - return _races != null ? _races : Collections.emptyList(); + return _races != null ? _races : Collections.emptySet(); } public void addRaceNot(Race race) { if (_racesNot == null) { - _racesNot = new ArrayList<>(); + _racesNot = EnumSet.noneOf(Race.class); } _racesNot.add(race); } - public List getRacesNot() + public Set getRacesNot() { - return _racesNot != null ? _racesNot : Collections.emptyList(); + return _racesNot != null ? _racesNot : Collections.emptySet(); } /** @@ -302,7 +303,7 @@ public class AppearanceStone { // Seems like in retail item with already changed appearance, can be changed again without being restored. - final AppearanceTargetType targetType = getTargetTypes().get(0); + final AppearanceTargetType targetType = getTargetTypes().stream().findFirst().get(); switch (targetType) { case NONE: diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java index 5d3a79d524..5e067a67e5 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java @@ -16,16 +16,16 @@ */ package org.l2jmobius.gameserver.model.item.enchant; +import java.util.EnumSet; +import java.util.Set; import java.util.logging.Logger; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.item.ItemTemplate; import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.model.item.type.CrystalType; import org.l2jmobius.gameserver.model.item.type.EtcItemType; -import org.l2jmobius.gameserver.model.item.type.ItemType; /** * @author UnAfraid @@ -34,26 +34,27 @@ public abstract class AbstractEnchantItem { protected static final Logger LOGGER = Logger.getLogger(AbstractEnchantItem.class.getName()); - private static final ItemType[] ENCHANT_TYPES = new ItemType[] + private static final Set ENCHANT_TYPES = EnumSet.noneOf(EtcItemType.class); + static { - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM, - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP, - EtcItemType.BLESS_ENCHT_AM, - EtcItemType.BLESS_ENCHT_AM_DOWN, - EtcItemType.BLESS_ENCHT_WP, - EtcItemType.ENCHT_AM, - EtcItemType.ENCHT_WP, - EtcItemType.GIANT_ENCHT_AM, - EtcItemType.GIANT_ENCHT_WP, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - }; + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + } private final int _id; private final CrystalType _grade; @@ -71,7 +72,7 @@ public abstract class AbstractEnchantItem { throw new NullPointerException(); } - else if (!CommonUtil.contains(ENCHANT_TYPES, getItem().getItemType())) + else if (!ENCHANT_TYPES.contains(getItem().getItemType())) { throw new IllegalAccessError(); } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java index 5ba6755084..18508d0145 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java @@ -24,8 +24,10 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Set; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -184,7 +186,7 @@ public class LongTimeEvent extends Quest final Node maxLevelNode = d.getAttributes().getNamedItem("maxLevel"); final int maxLevel = maxLevelNode == null ? Integer.MAX_VALUE : Integer.parseInt(maxLevelNode.getNodeValue()); final Node monsterIdsNode = d.getAttributes().getNamedItem("monsterIds"); - final List monsterIds = new ArrayList<>(); + final Set monsterIds = new HashSet<>(); if (monsterIdsNode != null) { for (String id : monsterIdsNode.getNodeValue().split(",")) diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/residences/ClanHall.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/residences/ClanHall.java index 0c0a529077..fcc850371b 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/residences/ClanHall.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/residences/ClanHall.java @@ -23,7 +23,9 @@ import java.sql.SQLException; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -61,9 +63,9 @@ public class ClanHall extends AbstractResidence private final int _minBid; final int _lease; private final int _deposit; - private final List _npcs; - private final List _doors; - private final List _teleports; + private final Set _npcs = new HashSet<>(); + private final Set _doors = new HashSet<>(); + private final Set _teleports = new HashSet<>(); private final Location _ownerLocation; private final Location _banishLocation; // Dynamic parameters @@ -85,9 +87,21 @@ public class ClanHall extends AbstractResidence _minBid = params.getInt("minBid"); _lease = params.getInt("lease"); _deposit = params.getInt("deposit"); - _npcs = params.getList("npcList", Integer.class); - _doors = params.getList("doorList", Door.class); - _teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + final List npcs = params.getList("npcList", Integer.class); + if (npcs != null) + { + _npcs.addAll(npcs); + } + final List doors = params.getList("doorList", Door.class); + if (doors != null) + { + _doors.addAll(doors); + } + final List teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + if (teleports != null) + { + _teleports.addAll(teleports); + } _ownerLocation = params.getLocation("owner_loc"); _banishLocation = params.getLocation("banish_loc"); // Set dynamic parameters (from DB) @@ -196,7 +210,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Door} related to this {@link ClanHall}. * @return all {@link Door} related to this {@link ClanHall} */ - public List getDoors() + public Set getDoors() { return _doors; } @@ -205,7 +219,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Npc} related to this {@link ClanHall}. * @return all {@link Npc} related to this {@link ClanHall} */ - public List getNpcs() + public Set getNpcs() { return _npcs; } @@ -324,7 +338,7 @@ public class ClanHall extends AbstractResidence return _banishLocation; } - public List getTeleportList() + public Set getTeleportList() { return _teleports; } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/siege/Castle.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/siege/Castle.java index d053196bec..4e90413baf 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/siege/Castle.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/siege/Castle.java @@ -21,8 +21,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.Calendar; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -83,7 +85,7 @@ public class Castle extends AbstractResidence private SiegeZone _zone = null; private ResidenceTeleportZone _teleZone; private Clan _formerOwner = null; - private final List _artefacts = new ArrayList<>(1); + private final Set _artefacts = new HashSet<>(1); private final Map _function = new ConcurrentHashMap<>(); private int _ticketBuyCount = 0; private boolean _isFirstMidVictory = false; @@ -1072,7 +1074,7 @@ public class Castle extends AbstractResidence _artefacts.add(artefact); } - public List getArtefacts() + public Set getArtefacts() { return _artefacts; } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java index 0c79677eae..4ebf954ee5 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.network.serverpackets; -import java.util.List; +import java.util.Set; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.gameserver.data.sql.CharNameTable; @@ -27,19 +27,19 @@ import org.l2jmobius.gameserver.network.OutgoingPackets; */ public class BlockListPacket implements IClientOutgoingPacket { - private final List _playersId; + private final Set _playerIds; - public BlockListPacket(List playersId) + public BlockListPacket(Set playerIds) { - _playersId = playersId; + _playerIds = playerIds; } @Override public boolean write(PacketWriter packet) { OutgoingPackets.BLOCK_LIST.writeId(packet); - packet.writeD(_playersId.size()); - for (int playerId : _playersId) + packet.writeD(_playerIds.size()); + for (int playerId : _playerIds) { packet.writeS(CharNameTable.getInstance().getNameById(playerId)); packet.writeS(""); // memo ? diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java index 8555bb6e86..eb5bfd05d8 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.network.serverpackets; import java.util.List; import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; import org.l2jmobius.commons.network.PacketWriter; @@ -37,7 +38,7 @@ public class ExAcquireSkillInfo implements IClientOutgoingPacket private final int _dualClassLevel; private final long _spCost; private final int _minLevel; - private final List _itemReq; + private final Set _itemReq; private final List _skillRem; /** diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java index 84b5fead76..a163a85735 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java @@ -35,7 +35,7 @@ public class ExChooseShapeShiftingItem implements IClientOutgoingPacket public ExChooseShapeShiftingItem(AppearanceStone stone) { _type = stone.getType(); - _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().get(0); + _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().stream().findFirst().get(); _itemId = stone.getId(); } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/DocumentBase.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/DocumentBase.java index 8a8e13d940..c22140b9c4 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/DocumentBase.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/DocumentBase.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.util; import java.io.File; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -390,12 +391,12 @@ public abstract class DocumentBase case "races": { final String[] racesVal = a.getNodeValue().split(","); - final Race[] races = new Race[racesVal.length]; + final Set races = EnumSet.noneOf(Race.class); for (int r = 0; r < racesVal.length; r++) { if (racesVal[r] != null) { - races[r] = Race.valueOf(racesVal[r]); + races.add(Race.valueOf(racesVal[r])); } } cond = joinAnd(cond, new ConditionPlayerRace(races)); @@ -671,13 +672,13 @@ public abstract class DocumentBase case "instanceid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final ArrayList array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInstanceId(array)); + cond = joinAnd(cond, new ConditionPlayerInstanceId(set)); break; } case "agathionid": @@ -728,10 +729,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -745,10 +746,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -834,13 +835,13 @@ public abstract class DocumentBase case "insidezoneid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInsideZoneId(array)); + cond = joinAnd(cond, new ConditionPlayerInsideZoneId(set)); break; } case "checkabnormal": @@ -961,13 +962,13 @@ public abstract class DocumentBase case "class_id_restriction": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetClassIdRestriction(array)); + cond = joinAnd(cond, new ConditionTargetClassIdRestriction(set)); break; } case "active_effect_id": @@ -1045,13 +1046,13 @@ public abstract class DocumentBase case "npcid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetNpcId(array)); + cond = joinAnd(cond, new ConditionTargetNpcId(set)); break; } case "npctype": diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/bypasshandlers/Link.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/bypasshandlers/Link.java index 380a9f1ae3..93bc7f3647 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/bypasshandlers/Link.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/bypasshandlers/Link.java @@ -16,7 +16,9 @@ */ package handlers.bypasshandlers; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.HashSet; +import java.util.Set; + import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.handler.IBypassHandler; import org.l2jmobius.gameserver.model.actor.Creature; @@ -31,37 +33,38 @@ public class Link implements IBypassHandler "Link" }; - private static final String[] VALID_LINKS = + private static final Set VALID_LINKS = new HashSet<>(); + static { - "common/craft_01.htm", - "common/craft_02.htm", - "common/runes_01.htm", - "common/sealed_runes_01.htm", - "common/sealed_runes_02.htm", - "common/sealed_runes_03.htm", - "common/sealed_runes_04.htm", - "common/sealed_runes_05.htm", - "common/sealed_runes_06.htm", - "common/sealed_runes_07.htm", - "common/sealed_runes_08.htm", - "common/sealed_runes_09.htm", - "common/skill_enchant_help_01.htm", - "common/skill_enchant_help_02.htm", - "common/skill_enchant_help_03.htm", - "default/BlessingOfProtection.htm", - "default/SupportMagic.htm", - "fisherman/fishing_manual001.htm", - "fisherman/fishing_manual002.htm", - "fisherman/fishing_manual003.htm", - "fisherman/fishing_manual004.htm", - "fisherman/fishing_manual005.htm", - "fortress/foreman.htm", - "petmanager/evolve.htm", - "petmanager/exchange.htm", - "petmanager/instructions.htm", - "warehouse/clanwh.htm", - "warehouse/privatewh.htm", - }; + VALID_LINKS.add("common/craft_01.htm"); + VALID_LINKS.add("common/craft_02.htm"); + VALID_LINKS.add("common/runes_01.htm"); + VALID_LINKS.add("common/runes_01.htm"); + VALID_LINKS.add("common/sealed_runes_02.htm"); + VALID_LINKS.add("common/sealed_runes_03.htm"); + VALID_LINKS.add("common/sealed_runes_04.htm"); + VALID_LINKS.add("common/sealed_runes_05.htm"); + VALID_LINKS.add("common/sealed_runes_06.htm"); + VALID_LINKS.add("common/sealed_runes_07.htm"); + VALID_LINKS.add("common/sealed_runes_08.htm"); + VALID_LINKS.add("common/sealed_runes_09.htm"); + VALID_LINKS.add("common/skill_enchant_help_01.htm"); + VALID_LINKS.add("common/skill_enchant_help_02.htm"); + VALID_LINKS.add("common/skill_enchant_help_03.htm"); + VALID_LINKS.add("default/BlessingOfProtection.htm"); + VALID_LINKS.add("default/SupportMagic.htm"); + VALID_LINKS.add("fisherman/fishing_manual001.htm"); + VALID_LINKS.add("fisherman/fishing_manual002.htm"); + VALID_LINKS.add("fisherman/fishing_manual003.htm"); + VALID_LINKS.add("fisherman/fishing_manual004.htm"); + VALID_LINKS.add("fisherman/fishing_manual008.htm"); + VALID_LINKS.add("fortress/foreman.htm"); + VALID_LINKS.add("petmanager/evolve.htm"); + VALID_LINKS.add("petmanager/exchange.htm"); + VALID_LINKS.add("petmanager/instructions.htm"); + VALID_LINKS.add("warehouse/clanwh.htm"); + VALID_LINKS.add("warehouse/privatewh.htm"); + } @Override public boolean useBypass(String command, Player player, Creature target) @@ -79,12 +82,13 @@ public class Link implements IBypassHandler return false; } - String content = CommonUtil.contains(VALID_LINKS, htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; + String content = VALID_LINKS.contains(htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; // Precaution. if (htmlPath.startsWith("teleporter/") && !(player.getTarget() instanceof Teleporter)) { content = null; } + final NpcHtmlMessage html = new NpcHtmlMessage(target != null ? target.getObjectId() : 0); if (content != null) { diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java index 6ff583ebec..a60d57f8f4 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java @@ -16,8 +16,9 @@ */ package handlers.dailymissionhandlers; -import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.Config; import org.l2jmobius.gameserver.enums.DailyMissionStatus; @@ -41,7 +42,7 @@ public class MonsterDailyMissionHandler extends AbstractDailyMissionHandler private final int _amount; private final int _minLevel; private final int _maxLevel; - private final List _ids = new ArrayList<>(); + private final Set _ids = new HashSet<>(); public MonsterDailyMissionHandler(DailyMissionDataHolder holder) { diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/itemhandlers/PetFood.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/itemhandlers/PetFood.java index 3c5572d4ec..8b908ea095 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/itemhandlers/PetFood.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/itemhandlers/PetFood.java @@ -17,6 +17,7 @@ package handlers.itemhandlers; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.PetDataTable; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -79,7 +80,7 @@ public class PetFood implements IItemHandler final Player player = activeChar.getActingPlayer(); if (player.isMounted()) { - final List foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); + final Set foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); if (foodIds.contains(item.getId()) && player.destroyItem("Consume", item.getObjectId(), 1, null, false)) { player.broadcastPacket(new MagicSkillUse(player, player, skillId, skillLevel, 0, 0)); diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java index 2ad282f683..99f45fbb41 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.ClanHallData; import org.l2jmobius.gameserver.model.StatSet; @@ -32,12 +33,12 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpCheckResidenceSkillCondition implements ISkillCondition { - private final List _residencesId; + private final Set _residencesId = new HashSet<>(); private final boolean _isWithin; public OpCheckResidenceSkillCondition(StatSet params) { - _residencesId = params.getList("residencesId", Integer.class); + _residencesId.addAll(params.getList("residencesId", Integer.class)); _isWithin = params.getBoolean("isWithin"); } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java index fc2934423b..4a8282d988 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java @@ -16,9 +16,9 @@ */ package handlers.skillconditionhandlers; -import java.util.ArrayList; -import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -28,18 +28,18 @@ import org.l2jmobius.gameserver.model.skill.ISkillCondition; import org.l2jmobius.gameserver.model.skill.Skill; /** - * @author UnAfraid + * @author UnAfraid, Mobius */ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition { - private final List _npcIds = new ArrayList<>(); + private final Set _npcIds = new HashSet<>(); public OpNeedSummonOrPetSkillCondition(StatSet params) { - final List npcIds = params.getList("npcIds", String.class); + final List npcIds = params.getList("npcIds", Integer.class); if (npcIds != null) { - npcIds.stream().map(Integer::valueOf).forEach(_npcIds::add); + _npcIds.addAll(npcIds); } } @@ -47,7 +47,19 @@ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition public boolean canUse(Creature caster, Skill skill, WorldObject target) { final Summon pet = caster.getPet(); - final Collection summons = caster.getServitors().values(); - return ((pet != null) && _npcIds.stream().anyMatch(npcId -> npcId == pet.getId())) || summons.stream().anyMatch(summon -> _npcIds.contains(summon.getId())); + if ((pet != null) && _npcIds.contains(pet.getId())) + { + return true; + } + + for (Summon summon : caster.getServitors().values()) + { + if (_npcIds.contains(summon.getId())) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java index 8541bc62b4..ef81b291d4 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,11 +30,11 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetDoorSkillCondition implements ISkillCondition { - private final List _doorIds; + private final Set _doorIds = new HashSet<>(); public OpTargetDoorSkillCondition(StatSet params) { - _doorIds = params.getList("doorIds", Integer.class); + _doorIds.addAll(params.getList("doorIds", Integer.class)); } @Override diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java index 3ce4145703..0ccd571e19 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,17 +30,17 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetNpcSkillCondition implements ISkillCondition { - private final List _npcId; + private final Set _npcIds = new HashSet<>(); public OpTargetNpcSkillCondition(StatSet params) { - _npcId = params.getList("npcIds", Integer.class); + _npcIds.addAll(params.getList("npcIds", Integer.class)); } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget(); - return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId()); + return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcIds.contains(actualTarget.getId()); } } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/instances/AbstractInstance.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/instances/AbstractInstance.java index d485c2c36d..4a0a3d35d4 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/instances/AbstractInstance.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/instances/AbstractInstance.java @@ -16,9 +16,10 @@ */ package instances; +import java.util.HashSet; import java.util.List; +import java.util.Set; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.enums.InstanceReenterType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.instancemanager.InstanceManager; @@ -40,25 +41,29 @@ import ai.AbstractNpcAI; */ public abstract class AbstractInstance extends AbstractNpcAI { - private final int[] _templateIds; + private final Set _templateIds = new HashSet<>(); - public AbstractInstance(int... templateId) + public AbstractInstance(int... templateIds) { - if (templateId.length == 0) + if (templateIds.length == 0) { throw new IllegalStateException("No template ids were provided!"); } - _templateIds = templateId; + + for (int templateId : templateIds) + { + _templateIds.add(templateId); + } } - public int[] getTemplateId() + public Set getTemplateId() { return _templateIds; } public boolean isInInstance(Instance instance) { - return (instance != null) && CommonUtil.contains(_templateIds, instance.getTemplateId()); + return (instance != null) && _templateIds.contains(instance.getTemplateId()); } /** diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/Config.java index 89d6093aba..7368ab9009 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/Config.java @@ -286,7 +286,7 @@ public class Config public static boolean AUTO_LOOT_SLOT_LIMIT; public static int LOOT_RAIDS_PRIVILEGE_INTERVAL; public static int LOOT_RAIDS_PRIVILEGE_CC_SIZE; - public static List AUTO_LOOT_ITEM_IDS; + public static Set AUTO_LOOT_ITEM_IDS; public static boolean ENABLE_KEYBOARD_MOVEMENT; public static int UNSTUCK_INTERVAL; public static int TELEPORT_WATCHDOG_TIMEOUT; @@ -476,7 +476,7 @@ public class Config public static boolean ALLOW_DISCARDITEM; public static int AUTODESTROY_ITEM_AFTER; public static int HERB_AUTO_DESTROY_TIME; - public static List LIST_PROTECTED_ITEMS; + public static Set LIST_PROTECTED_ITEMS; public static boolean DATABASE_CLEAN_UP; public static int CHAR_DATA_STORE_INTERVAL; public static int CLAN_VARIABLES_STORE_INTERVAL; @@ -567,7 +567,7 @@ public class Config public static boolean ALT_OLY_LOG_FIGHTS; public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS; public static boolean ALT_OLY_ANNOUNCE_GAMES; - public static List LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(); + public static Set LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(); public static int ALT_OLY_WEAPON_ENCHANT_LIMIT; public static int ALT_OLY_ARMOR_ENCHANT_LIMIT; public static int ALT_OLY_WAIT_TIME; @@ -1165,9 +1165,9 @@ public class Config public static int AUTO_CP_PERCENTAGE; public static int AUTO_HP_PERCENTAGE; public static int AUTO_MP_PERCENTAGE; - public static List AUTO_CP_ITEM_IDS; - public static List AUTO_HP_ITEM_IDS; - public static List AUTO_MP_ITEM_IDS; + public static Set AUTO_CP_ITEM_IDS; + public static Set AUTO_HP_ITEM_IDS; + public static Set AUTO_MP_ITEM_IDS; public static boolean CUSTOM_STARTING_LOC; public static int CUSTOM_STARTING_LOC_X; public static int CUSTOM_STARTING_LOC_Y; @@ -1177,7 +1177,7 @@ public class Config public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; public static int MOB_MIN_SPAWN_RANGE; public static int MOB_MAX_SPAWN_RANGE; - public static List MOBS_LIST_NOT_RANDOM; + public static Set MOBS_LIST_NOT_RANDOM; public static boolean FREE_JUMPS_FOR_ALL; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; @@ -1196,7 +1196,7 @@ public class Config public static boolean COMMUNITY_PREMIUM_SYSTEM_ENABLED; public static int COMMUNITY_PREMIUM_COIN_ID; public static int COMMUNITY_PREMIUM_PRICE_PER_DAY; - public static List COMMUNITY_AVAILABLE_BUFFS; + public static Set COMMUNITY_AVAILABLE_BUFFS; public static Map COMMUNITY_AVAILABLE_TELEPORTS; public static boolean CUSTOM_DEPOSITABLE_ENABLED; public static boolean CUSTOM_DEPOSITABLE_QUEST_ITEMS; @@ -1848,7 +1848,7 @@ public class Config LOOT_RAIDS_PRIVILEGE_INTERVAL = characterConfig.getInt("RaidLootRightsInterval", 900) * 1000; LOOT_RAIDS_PRIVILEGE_CC_SIZE = characterConfig.getInt("RaidLootRightsCCSize", 45); final String[] autoLootItemIds = characterConfig.getString("AutoLootItemIds", "0").split(","); - AUTO_LOOT_ITEM_IDS = new ArrayList<>(autoLootItemIds.length); + AUTO_LOOT_ITEM_IDS = new HashSet<>(autoLootItemIds.length); for (String item : autoLootItemIds) { Integer itm = 0; @@ -1968,7 +1968,7 @@ public class Config AUTODESTROY_ITEM_AFTER = generalConfig.getInt("AutoDestroyDroppedItemAfter", 600); HERB_AUTO_DESTROY_TIME = generalConfig.getInt("AutoDestroyHerbTime", 60) * 1000; final String[] split = generalConfig.getString("ListOfProtectedItems", "0").split(","); - LIST_PROTECTED_ITEMS = new ArrayList<>(split.length); + LIST_PROTECTED_ITEMS = new HashSet<>(split.length); for (String id : split) { LIST_PROTECTED_ITEMS.add(Integer.parseInt(id)); @@ -2362,7 +2362,7 @@ public class Config if (!olyRestrictedItems.isEmpty()) { final String[] olyRestrictedItemsSplit = olyRestrictedItems.split(","); - LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(olyRestrictedItemsSplit.length); + LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(olyRestrictedItemsSplit.length); for (String id : olyRestrictedItemsSplit) { LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id)); @@ -2476,17 +2476,17 @@ public class Config AUTO_CP_PERCENTAGE = autoPotionsConfig.getInt("AutoCpPercentage", 70); AUTO_HP_PERCENTAGE = autoPotionsConfig.getInt("AutoHpPercentage", 70); AUTO_MP_PERCENTAGE = autoPotionsConfig.getInt("AutoMpPercentage", 70); - AUTO_CP_ITEM_IDS = new ArrayList<>(); + AUTO_CP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoCpItemIds", "0").split(",")) { AUTO_CP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_HP_ITEM_IDS = new ArrayList<>(); + AUTO_HP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoHpItemIds", "0").split(",")) { AUTO_HP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_MP_ITEM_IDS = new ArrayList<>(); + AUTO_MP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoMpItemIds", "0").split(",")) { AUTO_MP_ITEM_IDS.add(Integer.parseInt(s)); @@ -3096,7 +3096,7 @@ public class Config COMMUNITY_PREMIUM_COIN_ID = communityBoardConfig.getInt("CommunityPremiumBuyCoinId", 57); COMMUNITY_PREMIUM_PRICE_PER_DAY = communityBoardConfig.getInt("CommunityPremiumPricePerDay", 1000000); final String[] allowedBuffs = communityBoardConfig.getString("CommunityAvailableBuffs", "").split(","); - COMMUNITY_AVAILABLE_BUFFS = new ArrayList<>(allowedBuffs.length); + COMMUNITY_AVAILABLE_BUFFS = new HashSet<>(allowedBuffs.length); for (String s : allowedBuffs) { COMMUNITY_AVAILABLE_BUFFS.add(Integer.parseInt(s)); @@ -3416,7 +3416,7 @@ public class Config if (ENABLE_RANDOM_MONSTER_SPAWNS) { final String[] mobsIds = randomSpawnsConfig.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); - MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + MOBS_LIST_NOT_RANDOM = new HashSet<>(mobsIds.length); for (String id : mobsIds) { MOBS_LIST_NOT_RANDOM.add(Integer.parseInt(id)); diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java index d6e0183c6f..c3977185b4 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java @@ -202,8 +202,7 @@ public class ClanHallData implements IXmlReader final Door door = DoorData.getInstance().getDoor(doorId); for (ClanHall ch : _clanHalls.values()) { - final List doors = ch.getDoors(); - if ((doors != null) && doors.contains(door)) + if (ch.getDoors().contains(door)) { return ch; } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java index 6aa0a1fdde..fb395b9e2d 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java @@ -17,10 +17,10 @@ package org.l2jmobius.gameserver.data.xml; import java.io.File; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -42,7 +42,7 @@ public class FakePlayerData implements IXmlReader private final Map _fakePlayerInfos = new HashMap<>(); private final Map _fakePlayerNames = new HashMap<>(); private final Map _fakePlayerIds = new HashMap<>(); - private final List _talkableFakePlayerNames = new ArrayList<>(); + private final Set _talkableFakePlayerNames = new HashSet<>(); protected FakePlayerData() { diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java index d335b95954..1122d7b9ba 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java @@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -49,7 +51,7 @@ import org.l2jmobius.gameserver.util.Util; public class SellBuffsManager implements IXmlReader { private static final Logger LOGGER = Logger.getLogger(SellBuffsManager.class.getName()); - private static final List ALLOWED_BUFFS = new ArrayList<>(); + private static final Set ALLOWED_BUFFS = new HashSet<>(); private static final String HTML_FOLDER = "data/html/mods/SellBuffs/"; protected SellBuffsManager() @@ -76,11 +78,7 @@ public class SellBuffsManager implements IXmlReader { final Element elem = (Element) node.item(i); final int skillId = Integer.parseInt(elem.getAttribute("id")); - - if (!ALLOWED_BUFFS.contains(skillId)) - { - ALLOWED_BUFFS.add(skillId); - } + ALLOWED_BUFFS.add(skillId); } } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java index b10f75ef3d..1e45a21319 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java @@ -19,8 +19,10 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; @@ -67,7 +69,7 @@ public class WalkingManager implements IXmlReader public static final byte REPEAT_TELE_FIRST = 2; public static final byte REPEAT_RANDOM = 3; - private final List _targetedNpcIds = new ArrayList<>(); + private final Set _targetedNpcIds = new HashSet<>(); private final Map _routes = new HashMap<>(); // all available routes private final Map _activeRoutes = new HashMap<>(); // each record represents NPC, moving by predefined route from _routes, and moving progress private final Map _routesToAttach = new HashMap<>(); // each record represents NPC and all available routes for it diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/BlockList.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/BlockList.java index 1af9941ed5..9ac6266e22 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/BlockList.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/BlockList.java @@ -19,9 +19,9 @@ package org.l2jmobius.gameserver.model; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -36,10 +36,11 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; public class BlockList { private static final Logger LOGGER = Logger.getLogger(BlockList.class.getName()); - private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); + + private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); private final Player _owner; - private List _blockList; + private Set _blockList; public BlockList(Player owner) { @@ -68,9 +69,9 @@ public class BlockList OFFLINE_LIST.put(_owner.getObjectId(), _blockList); } - private static List loadList(int objId) + private static Set loadList(int objId) { - final List list = new ArrayList<>(); + final Set list = new HashSet<>(); try (Connection con = DatabaseFactory.getConnection(); PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1")) { @@ -158,7 +159,7 @@ public class BlockList _owner.setMessageRefusal(value); } - private List getBlockList() + private Set getBlockList() { return _blockList; } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/PetData.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/PetData.java index b534c21f36..231b85e85f 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/PetData.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/PetData.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; import org.l2jmobius.gameserver.model.holders.SkillHolder; @@ -40,7 +42,7 @@ public class PetData private int _minLevel = Byte.MAX_VALUE; private int _maxLevel = 0; private boolean _syncLevel = false; - private final List _food = new ArrayList<>(); + private final Set _food = new HashSet<>(); public PetData(int npcId, int itemId) { @@ -133,7 +135,7 @@ public class PetData /** * @return the pet's food list. */ - public List getFood() + public Set getFood() { return _food; } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/SkillLearn.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/SkillLearn.java index a69d30f105..3d5704b5f2 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/SkillLearn.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/SkillLearn.java @@ -16,9 +16,8 @@ */ package org.l2jmobius.gameserver.model; -import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashSet; -import java.util.List; import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -40,12 +39,12 @@ public class SkillLearn private final int _getDualClassLevel; private final boolean _autoGet; private final long _levelUpSp; - private final List _requiredItems = new ArrayList<>(); - private final List _races = new ArrayList<>(); - private final List _preReqSkills = new ArrayList<>(); + private final Set _requiredItems = new HashSet<>(1); + private final Set _races = EnumSet.noneOf(Race.class); + private final Set _preReqSkills = new HashSet<>(1); private SocialClass _socialClass; private final boolean _residenceSkill; - private final List _residenceIds = new ArrayList<>(); + private final Set _residenceIds = new HashSet<>(1); private final boolean _learnedByNpc; private final boolean _learnedByFS; private final Set _removeSkills = new HashSet<>(1); @@ -133,9 +132,9 @@ public class SkillLearn } /** - * @return the list with the item holders required to acquire this skill. + * @return the set with the item holders required to acquire this skill. */ - public List getRequiredItems() + public Set getRequiredItems() { return _requiredItems; } @@ -150,9 +149,9 @@ public class SkillLearn } /** - * @return a list with the races that can acquire this skill. + * @return a set with the races that can acquire this skill. */ - public List getRaces() + public Set getRaces() { return _races; } @@ -167,9 +166,9 @@ public class SkillLearn } /** - * @return the list of skill holders required to acquire this skill. + * @return the set of skill holders required to acquire this skill. */ - public List getPreReqSkills() + public Set getPreReqSkills() { return _preReqSkills; } @@ -212,9 +211,9 @@ public class SkillLearn } /** - * @return a list with the Ids where this skill is available. + * @return a set with the Ids where this skill is available. */ - public List getResidenceIds() + public Set getResidenceIds() { return _residenceIds; } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java index 76d810a2d9..3b04eafa72 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java @@ -22,7 +22,6 @@ import java.sql.ResultSet; import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.List; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; @@ -153,7 +152,7 @@ public class Pet extends Summon broadcastStatusUpdate(); - final List foodIds = getPetData().getFood(); + final Set foodIds = getPetData().getFood(); if (foodIds.isEmpty()) { if (isUncontrollable()) diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java index ddd5c20f5c..650e0257d2 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java @@ -16,8 +16,8 @@ */ package org.l2jmobius.gameserver.model.actor.instance; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import org.l2jmobius.commons.threads.ThreadPool; @@ -57,7 +57,7 @@ public class Trap extends Npc private boolean _isTriggered; private final int _lifeTime; private Player _owner; - private final List _playersWhoDetectedMe = new ArrayList<>(); + private final Set _playersWhoDetectedMe = new HashSet<>(); private final SkillHolder _skill; private int _remainingTime; // Tasks diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java index 71ef076212..3ba8c20a9b 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor.tasks.player; -import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -69,11 +69,12 @@ public class PetFeedTask implements Runnable _player.sendPacket(SystemMessageId.YOU_ARE_OUT_OF_FEED_MOUNT_STATUS_CANCELED); } - final List foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); + final Set foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); if (foodIds.isEmpty()) { return; } + Item food = null; for (int id : foodIds) { diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java index 50d2a821c3..2611b5f121 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.actor.Creature; @@ -29,9 +29,9 @@ import org.l2jmobius.gameserver.model.zone.ZoneType; */ public class ConditionPlayerInsideZoneId extends Condition { - private final List _zones; + private final Set _zones; - public ConditionPlayerInsideZoneId(List zones) + public ConditionPlayerInsideZoneId(Set zones) { _zones = zones; } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java index c15065eca2..d644f663f5 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Player; @@ -29,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerInstanceId extends Condition { - private final List _instanceIds; + private final Set _instanceIds; /** * Instantiates a new condition player instance id. * @param instanceIds the instance ids */ - public ConditionPlayerInstanceId(List instanceIds) + public ConditionPlayerInstanceId(Set instanceIds) { _instanceIds = instanceIds; } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java index 14d61089ed..7c375ec45e 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -28,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerRace extends Condition { - private final Race[] _races; + private final Set _races; /** * Instantiates a new condition player race. * @param races the list containing the allowed races. */ - public ConditionPlayerRace(Race[] races) + public ConditionPlayerRace(Set races) { _races = races; } @@ -46,6 +47,6 @@ public class ConditionPlayerRace extends Condition { return false; } - return CommonUtil.contains(_races, effector.getActingPlayer().getRace()); + return _races.contains(effector.getActingPlayer().getRace()); } } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java index 0f54766571..0b326e3f40 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId())) + if (_npcIds.contains(target.getId())) { existNpc = true; break; diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java index c5c9b5ff0e..db64b6bd7b 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromSummonedNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromSummonedNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromSummonedNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromSummonedNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId()) && (effector == target.getSummoner())) + if (_npcIds.contains(target.getId()) && (effector == target.getSummoner())) { existNpc = true; break; diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java index a3fb0f5374..a47b4b4983 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetClassIdRestriction extends Condition { - private final List _classIds; + private final Set _classIds; /** * Instantiates a new condition target class id restriction. * @param classId the class id */ - public ConditionTargetClassIdRestriction(List classId) + public ConditionTargetClassIdRestriction(Set classId) { _classIds = classId; } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java index 82b1bd5877..9bb694f4ef 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetNpcId extends Condition { - private final List _npcIds; + private final Set _npcIds; /** * Instantiates a new condition target npc id. * @param npcIds the npc ids */ - public ConditionTargetNpcId(List npcIds) + public ConditionTargetNpcId(Set npcIds) { _npcIds = npcIds; } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java index f26329bc21..5c86f26ae5 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.holders; -import java.util.Collection; +import java.util.Set; /** * @author Mobius @@ -25,9 +25,9 @@ public class EventDropHolder extends DropHolder { private final int _minLevel; private final int _maxLevel; - private final Collection _monsterIds; + private final Set _monsterIds; - public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Collection monsterIds) + public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Set monsterIds) { super(null, itemId, min, max, chance); _minLevel = minLevel; @@ -45,7 +45,7 @@ public class EventDropHolder extends DropHolder return _maxLevel; } - public Collection getMonsterIds() + public Set getMonsterIds() { return _monsterIds; } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/item/Henna.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/item/Henna.java index 107656dba9..3fa8d06bc6 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/item/Henna.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/item/Henna.java @@ -17,9 +17,11 @@ package org.l2jmobius.gameserver.model.item; import java.util.ArrayList; -import java.util.HashMap; +import java.util.EnumMap; +import java.util.EnumSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.enums.ClassId; import org.l2jmobius.gameserver.model.StatSet; @@ -34,14 +36,14 @@ public class Henna { private final int _dyeId; private final int _dyeItemId; - private final Map _baseStats = new HashMap<>(); + private final Map _baseStats = new EnumMap<>(BaseStat.class); private final int _wearFee; private final int _wearCount; private final int _cancelFee; private final int _cancelCount; private final int _duration; private final List _skills; - private final List _wearClass; + private final Set _wearClass; public Henna(StatSet set) { @@ -59,7 +61,7 @@ public class Henna _cancelCount = set.getInt("cancel_count"); _duration = set.getInt("duration", -1); _skills = new ArrayList<>(); - _wearClass = new ArrayList<>(); + _wearClass = EnumSet.noneOf(ClassId.class); } /** @@ -147,7 +149,7 @@ public class Henna /** * @return the list with the allowed classes to wear this dye. */ - public List getAllowedWearClass() + public Set getAllowedWearClass() { return _wearClass; } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java index d74b1218d3..5d694e5169 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java @@ -17,9 +17,10 @@ package org.l2jmobius.gameserver.model.item.appearance; import java.time.Duration; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.enums.Race; @@ -47,12 +48,12 @@ public class AppearanceStone private final ArmorType _armorType; private final AppearanceHandType _handType; private final AppearanceMagicType _magicType; - private List _crystalTypes; - private List _targetTypes; - private List _bodyParts; - private List _races; - private List _racesNot; - private List _allVisualIds; + private Set _crystalTypes; + private Set _targetTypes; + private Set _bodyParts; + private Set _races; + private Set _racesNot; + private Set _allVisualIds; public AppearanceStone(StatSet set) { @@ -172,35 +173,35 @@ public class AppearanceStone { if (_crystalTypes == null) { - _crystalTypes = new ArrayList<>(); + _crystalTypes = EnumSet.noneOf(CrystalType.class); } _crystalTypes.add(type); } - public List getCrystalTypes() + public Set getCrystalTypes() { - return _crystalTypes != null ? _crystalTypes : Collections.emptyList(); + return _crystalTypes != null ? _crystalTypes : Collections.emptySet(); } public void addTargetType(AppearanceTargetType type) { if (_targetTypes == null) { - _targetTypes = new ArrayList<>(); + _targetTypes = EnumSet.noneOf(AppearanceTargetType.class); } _targetTypes.add(type); } - public List getTargetTypes() + public Set getTargetTypes() { - return _targetTypes != null ? _targetTypes : Collections.emptyList(); + return _targetTypes != null ? _targetTypes : Collections.emptySet(); } public void addBodyPart(long part) { if (_bodyParts == null) { - _bodyParts = new ArrayList<>(); + _bodyParts = new HashSet<>(); } _bodyParts.add(part); } @@ -209,47 +210,47 @@ public class AppearanceStone { if (_allVisualIds == null) { - _allVisualIds = new ArrayList<>(); + _allVisualIds = new HashSet<>(); } _allVisualIds.add(appearanceHolder); } - public List getVisualIds() + public Set getVisualIds() { - return _allVisualIds != null ? _allVisualIds : Collections.emptyList(); + return _allVisualIds != null ? _allVisualIds : Collections.emptySet(); } - public List getBodyParts() + public Set getBodyParts() { - return _bodyParts != null ? _bodyParts : Collections.emptyList(); + return _bodyParts != null ? _bodyParts : Collections.emptySet(); } public void addRace(Race race) { if (_races == null) { - _races = new ArrayList<>(); + _races = EnumSet.noneOf(Race.class); } _races.add(race); } - public List getRaces() + public Set getRaces() { - return _races != null ? _races : Collections.emptyList(); + return _races != null ? _races : Collections.emptySet(); } public void addRaceNot(Race race) { if (_racesNot == null) { - _racesNot = new ArrayList<>(); + _racesNot = EnumSet.noneOf(Race.class); } _racesNot.add(race); } - public List getRacesNot() + public Set getRacesNot() { - return _racesNot != null ? _racesNot : Collections.emptyList(); + return _racesNot != null ? _racesNot : Collections.emptySet(); } /** @@ -302,7 +303,7 @@ public class AppearanceStone { // Seems like in retail item with already changed appearance, can be changed again without being restored. - final AppearanceTargetType targetType = getTargetTypes().get(0); + final AppearanceTargetType targetType = getTargetTypes().stream().findFirst().get(); switch (targetType) { case NONE: diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java index 5d3a79d524..5e067a67e5 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java @@ -16,16 +16,16 @@ */ package org.l2jmobius.gameserver.model.item.enchant; +import java.util.EnumSet; +import java.util.Set; import java.util.logging.Logger; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.item.ItemTemplate; import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.model.item.type.CrystalType; import org.l2jmobius.gameserver.model.item.type.EtcItemType; -import org.l2jmobius.gameserver.model.item.type.ItemType; /** * @author UnAfraid @@ -34,26 +34,27 @@ public abstract class AbstractEnchantItem { protected static final Logger LOGGER = Logger.getLogger(AbstractEnchantItem.class.getName()); - private static final ItemType[] ENCHANT_TYPES = new ItemType[] + private static final Set ENCHANT_TYPES = EnumSet.noneOf(EtcItemType.class); + static { - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM, - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP, - EtcItemType.BLESS_ENCHT_AM, - EtcItemType.BLESS_ENCHT_AM_DOWN, - EtcItemType.BLESS_ENCHT_WP, - EtcItemType.ENCHT_AM, - EtcItemType.ENCHT_WP, - EtcItemType.GIANT_ENCHT_AM, - EtcItemType.GIANT_ENCHT_WP, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - }; + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + } private final int _id; private final CrystalType _grade; @@ -71,7 +72,7 @@ public abstract class AbstractEnchantItem { throw new NullPointerException(); } - else if (!CommonUtil.contains(ENCHANT_TYPES, getItem().getItemType())) + else if (!ENCHANT_TYPES.contains(getItem().getItemType())) { throw new IllegalAccessError(); } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java index 5ba6755084..18508d0145 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java @@ -24,8 +24,10 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Set; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -184,7 +186,7 @@ public class LongTimeEvent extends Quest final Node maxLevelNode = d.getAttributes().getNamedItem("maxLevel"); final int maxLevel = maxLevelNode == null ? Integer.MAX_VALUE : Integer.parseInt(maxLevelNode.getNodeValue()); final Node monsterIdsNode = d.getAttributes().getNamedItem("monsterIds"); - final List monsterIds = new ArrayList<>(); + final Set monsterIds = new HashSet<>(); if (monsterIdsNode != null) { for (String id : monsterIdsNode.getNodeValue().split(",")) diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/residences/ClanHall.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/residences/ClanHall.java index 0c0a529077..fcc850371b 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/residences/ClanHall.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/residences/ClanHall.java @@ -23,7 +23,9 @@ import java.sql.SQLException; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -61,9 +63,9 @@ public class ClanHall extends AbstractResidence private final int _minBid; final int _lease; private final int _deposit; - private final List _npcs; - private final List _doors; - private final List _teleports; + private final Set _npcs = new HashSet<>(); + private final Set _doors = new HashSet<>(); + private final Set _teleports = new HashSet<>(); private final Location _ownerLocation; private final Location _banishLocation; // Dynamic parameters @@ -85,9 +87,21 @@ public class ClanHall extends AbstractResidence _minBid = params.getInt("minBid"); _lease = params.getInt("lease"); _deposit = params.getInt("deposit"); - _npcs = params.getList("npcList", Integer.class); - _doors = params.getList("doorList", Door.class); - _teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + final List npcs = params.getList("npcList", Integer.class); + if (npcs != null) + { + _npcs.addAll(npcs); + } + final List doors = params.getList("doorList", Door.class); + if (doors != null) + { + _doors.addAll(doors); + } + final List teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + if (teleports != null) + { + _teleports.addAll(teleports); + } _ownerLocation = params.getLocation("owner_loc"); _banishLocation = params.getLocation("banish_loc"); // Set dynamic parameters (from DB) @@ -196,7 +210,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Door} related to this {@link ClanHall}. * @return all {@link Door} related to this {@link ClanHall} */ - public List getDoors() + public Set getDoors() { return _doors; } @@ -205,7 +219,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Npc} related to this {@link ClanHall}. * @return all {@link Npc} related to this {@link ClanHall} */ - public List getNpcs() + public Set getNpcs() { return _npcs; } @@ -324,7 +338,7 @@ public class ClanHall extends AbstractResidence return _banishLocation; } - public List getTeleportList() + public Set getTeleportList() { return _teleports; } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/siege/Castle.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/siege/Castle.java index d053196bec..4e90413baf 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/siege/Castle.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/siege/Castle.java @@ -21,8 +21,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.Calendar; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -83,7 +85,7 @@ public class Castle extends AbstractResidence private SiegeZone _zone = null; private ResidenceTeleportZone _teleZone; private Clan _formerOwner = null; - private final List _artefacts = new ArrayList<>(1); + private final Set _artefacts = new HashSet<>(1); private final Map _function = new ConcurrentHashMap<>(); private int _ticketBuyCount = 0; private boolean _isFirstMidVictory = false; @@ -1072,7 +1074,7 @@ public class Castle extends AbstractResidence _artefacts.add(artefact); } - public List getArtefacts() + public Set getArtefacts() { return _artefacts; } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java index 0c79677eae..4ebf954ee5 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.network.serverpackets; -import java.util.List; +import java.util.Set; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.gameserver.data.sql.CharNameTable; @@ -27,19 +27,19 @@ import org.l2jmobius.gameserver.network.OutgoingPackets; */ public class BlockListPacket implements IClientOutgoingPacket { - private final List _playersId; + private final Set _playerIds; - public BlockListPacket(List playersId) + public BlockListPacket(Set playerIds) { - _playersId = playersId; + _playerIds = playerIds; } @Override public boolean write(PacketWriter packet) { OutgoingPackets.BLOCK_LIST.writeId(packet); - packet.writeD(_playersId.size()); - for (int playerId : _playersId) + packet.writeD(_playerIds.size()); + for (int playerId : _playerIds) { packet.writeS(CharNameTable.getInstance().getNameById(playerId)); packet.writeS(""); // memo ? diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java index 8555bb6e86..eb5bfd05d8 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.network.serverpackets; import java.util.List; import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; import org.l2jmobius.commons.network.PacketWriter; @@ -37,7 +38,7 @@ public class ExAcquireSkillInfo implements IClientOutgoingPacket private final int _dualClassLevel; private final long _spCost; private final int _minLevel; - private final List _itemReq; + private final Set _itemReq; private final List _skillRem; /** diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java index 84b5fead76..a163a85735 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java @@ -35,7 +35,7 @@ public class ExChooseShapeShiftingItem implements IClientOutgoingPacket public ExChooseShapeShiftingItem(AppearanceStone stone) { _type = stone.getType(); - _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().get(0); + _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().stream().findFirst().get(); _itemId = stone.getId(); } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/DocumentBase.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/DocumentBase.java index 8a8e13d940..c22140b9c4 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/DocumentBase.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/DocumentBase.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.util; import java.io.File; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -390,12 +391,12 @@ public abstract class DocumentBase case "races": { final String[] racesVal = a.getNodeValue().split(","); - final Race[] races = new Race[racesVal.length]; + final Set races = EnumSet.noneOf(Race.class); for (int r = 0; r < racesVal.length; r++) { if (racesVal[r] != null) { - races[r] = Race.valueOf(racesVal[r]); + races.add(Race.valueOf(racesVal[r])); } } cond = joinAnd(cond, new ConditionPlayerRace(races)); @@ -671,13 +672,13 @@ public abstract class DocumentBase case "instanceid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final ArrayList array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInstanceId(array)); + cond = joinAnd(cond, new ConditionPlayerInstanceId(set)); break; } case "agathionid": @@ -728,10 +729,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -745,10 +746,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -834,13 +835,13 @@ public abstract class DocumentBase case "insidezoneid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInsideZoneId(array)); + cond = joinAnd(cond, new ConditionPlayerInsideZoneId(set)); break; } case "checkabnormal": @@ -961,13 +962,13 @@ public abstract class DocumentBase case "class_id_restriction": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetClassIdRestriction(array)); + cond = joinAnd(cond, new ConditionTargetClassIdRestriction(set)); break; } case "active_effect_id": @@ -1045,13 +1046,13 @@ public abstract class DocumentBase case "npcid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetNpcId(array)); + cond = joinAnd(cond, new ConditionTargetNpcId(set)); break; } case "npctype": diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/bypasshandlers/Link.java b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/bypasshandlers/Link.java index 380a9f1ae3..93bc7f3647 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/bypasshandlers/Link.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/bypasshandlers/Link.java @@ -16,7 +16,9 @@ */ package handlers.bypasshandlers; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.HashSet; +import java.util.Set; + import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.handler.IBypassHandler; import org.l2jmobius.gameserver.model.actor.Creature; @@ -31,37 +33,38 @@ public class Link implements IBypassHandler "Link" }; - private static final String[] VALID_LINKS = + private static final Set VALID_LINKS = new HashSet<>(); + static { - "common/craft_01.htm", - "common/craft_02.htm", - "common/runes_01.htm", - "common/sealed_runes_01.htm", - "common/sealed_runes_02.htm", - "common/sealed_runes_03.htm", - "common/sealed_runes_04.htm", - "common/sealed_runes_05.htm", - "common/sealed_runes_06.htm", - "common/sealed_runes_07.htm", - "common/sealed_runes_08.htm", - "common/sealed_runes_09.htm", - "common/skill_enchant_help_01.htm", - "common/skill_enchant_help_02.htm", - "common/skill_enchant_help_03.htm", - "default/BlessingOfProtection.htm", - "default/SupportMagic.htm", - "fisherman/fishing_manual001.htm", - "fisherman/fishing_manual002.htm", - "fisherman/fishing_manual003.htm", - "fisherman/fishing_manual004.htm", - "fisherman/fishing_manual005.htm", - "fortress/foreman.htm", - "petmanager/evolve.htm", - "petmanager/exchange.htm", - "petmanager/instructions.htm", - "warehouse/clanwh.htm", - "warehouse/privatewh.htm", - }; + VALID_LINKS.add("common/craft_01.htm"); + VALID_LINKS.add("common/craft_02.htm"); + VALID_LINKS.add("common/runes_01.htm"); + VALID_LINKS.add("common/runes_01.htm"); + VALID_LINKS.add("common/sealed_runes_02.htm"); + VALID_LINKS.add("common/sealed_runes_03.htm"); + VALID_LINKS.add("common/sealed_runes_04.htm"); + VALID_LINKS.add("common/sealed_runes_05.htm"); + VALID_LINKS.add("common/sealed_runes_06.htm"); + VALID_LINKS.add("common/sealed_runes_07.htm"); + VALID_LINKS.add("common/sealed_runes_08.htm"); + VALID_LINKS.add("common/sealed_runes_09.htm"); + VALID_LINKS.add("common/skill_enchant_help_01.htm"); + VALID_LINKS.add("common/skill_enchant_help_02.htm"); + VALID_LINKS.add("common/skill_enchant_help_03.htm"); + VALID_LINKS.add("default/BlessingOfProtection.htm"); + VALID_LINKS.add("default/SupportMagic.htm"); + VALID_LINKS.add("fisherman/fishing_manual001.htm"); + VALID_LINKS.add("fisherman/fishing_manual002.htm"); + VALID_LINKS.add("fisherman/fishing_manual003.htm"); + VALID_LINKS.add("fisherman/fishing_manual004.htm"); + VALID_LINKS.add("fisherman/fishing_manual008.htm"); + VALID_LINKS.add("fortress/foreman.htm"); + VALID_LINKS.add("petmanager/evolve.htm"); + VALID_LINKS.add("petmanager/exchange.htm"); + VALID_LINKS.add("petmanager/instructions.htm"); + VALID_LINKS.add("warehouse/clanwh.htm"); + VALID_LINKS.add("warehouse/privatewh.htm"); + } @Override public boolean useBypass(String command, Player player, Creature target) @@ -79,12 +82,13 @@ public class Link implements IBypassHandler return false; } - String content = CommonUtil.contains(VALID_LINKS, htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; + String content = VALID_LINKS.contains(htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; // Precaution. if (htmlPath.startsWith("teleporter/") && !(player.getTarget() instanceof Teleporter)) { content = null; } + final NpcHtmlMessage html = new NpcHtmlMessage(target != null ? target.getObjectId() : 0); if (content != null) { diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java index 6ff583ebec..a60d57f8f4 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java @@ -16,8 +16,9 @@ */ package handlers.dailymissionhandlers; -import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.Config; import org.l2jmobius.gameserver.enums.DailyMissionStatus; @@ -41,7 +42,7 @@ public class MonsterDailyMissionHandler extends AbstractDailyMissionHandler private final int _amount; private final int _minLevel; private final int _maxLevel; - private final List _ids = new ArrayList<>(); + private final Set _ids = new HashSet<>(); public MonsterDailyMissionHandler(DailyMissionDataHolder holder) { diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/itemhandlers/PetFood.java b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/itemhandlers/PetFood.java index 3c5572d4ec..8b908ea095 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/itemhandlers/PetFood.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/itemhandlers/PetFood.java @@ -17,6 +17,7 @@ package handlers.itemhandlers; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.PetDataTable; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -79,7 +80,7 @@ public class PetFood implements IItemHandler final Player player = activeChar.getActingPlayer(); if (player.isMounted()) { - final List foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); + final Set foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); if (foodIds.contains(item.getId()) && player.destroyItem("Consume", item.getObjectId(), 1, null, false)) { player.broadcastPacket(new MagicSkillUse(player, player, skillId, skillLevel, 0, 0)); diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java index 2ad282f683..99f45fbb41 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.ClanHallData; import org.l2jmobius.gameserver.model.StatSet; @@ -32,12 +33,12 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpCheckResidenceSkillCondition implements ISkillCondition { - private final List _residencesId; + private final Set _residencesId = new HashSet<>(); private final boolean _isWithin; public OpCheckResidenceSkillCondition(StatSet params) { - _residencesId = params.getList("residencesId", Integer.class); + _residencesId.addAll(params.getList("residencesId", Integer.class)); _isWithin = params.getBoolean("isWithin"); } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java index fc2934423b..4a8282d988 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java @@ -16,9 +16,9 @@ */ package handlers.skillconditionhandlers; -import java.util.ArrayList; -import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -28,18 +28,18 @@ import org.l2jmobius.gameserver.model.skill.ISkillCondition; import org.l2jmobius.gameserver.model.skill.Skill; /** - * @author UnAfraid + * @author UnAfraid, Mobius */ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition { - private final List _npcIds = new ArrayList<>(); + private final Set _npcIds = new HashSet<>(); public OpNeedSummonOrPetSkillCondition(StatSet params) { - final List npcIds = params.getList("npcIds", String.class); + final List npcIds = params.getList("npcIds", Integer.class); if (npcIds != null) { - npcIds.stream().map(Integer::valueOf).forEach(_npcIds::add); + _npcIds.addAll(npcIds); } } @@ -47,7 +47,19 @@ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition public boolean canUse(Creature caster, Skill skill, WorldObject target) { final Summon pet = caster.getPet(); - final Collection summons = caster.getServitors().values(); - return ((pet != null) && _npcIds.stream().anyMatch(npcId -> npcId == pet.getId())) || summons.stream().anyMatch(summon -> _npcIds.contains(summon.getId())); + if ((pet != null) && _npcIds.contains(pet.getId())) + { + return true; + } + + for (Summon summon : caster.getServitors().values()) + { + if (_npcIds.contains(summon.getId())) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java index 8541bc62b4..ef81b291d4 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,11 +30,11 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetDoorSkillCondition implements ISkillCondition { - private final List _doorIds; + private final Set _doorIds = new HashSet<>(); public OpTargetDoorSkillCondition(StatSet params) { - _doorIds = params.getList("doorIds", Integer.class); + _doorIds.addAll(params.getList("doorIds", Integer.class)); } @Override diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java index 3ce4145703..0ccd571e19 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,17 +30,17 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetNpcSkillCondition implements ISkillCondition { - private final List _npcId; + private final Set _npcIds = new HashSet<>(); public OpTargetNpcSkillCondition(StatSet params) { - _npcId = params.getList("npcIds", Integer.class); + _npcIds.addAll(params.getList("npcIds", Integer.class)); } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget(); - return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId()); + return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcIds.contains(actualTarget.getId()); } } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/instances/AbstractInstance.java b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/instances/AbstractInstance.java index d485c2c36d..4a0a3d35d4 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/instances/AbstractInstance.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/instances/AbstractInstance.java @@ -16,9 +16,10 @@ */ package instances; +import java.util.HashSet; import java.util.List; +import java.util.Set; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.enums.InstanceReenterType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.instancemanager.InstanceManager; @@ -40,25 +41,29 @@ import ai.AbstractNpcAI; */ public abstract class AbstractInstance extends AbstractNpcAI { - private final int[] _templateIds; + private final Set _templateIds = new HashSet<>(); - public AbstractInstance(int... templateId) + public AbstractInstance(int... templateIds) { - if (templateId.length == 0) + if (templateIds.length == 0) { throw new IllegalStateException("No template ids were provided!"); } - _templateIds = templateId; + + for (int templateId : templateIds) + { + _templateIds.add(templateId); + } } - public int[] getTemplateId() + public Set getTemplateId() { return _templateIds; } public boolean isInInstance(Instance instance) { - return (instance != null) && CommonUtil.contains(_templateIds, instance.getTemplateId()); + return (instance != null) && _templateIds.contains(instance.getTemplateId()); } /** diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/Config.java index eb610222f9..172326cacb 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/Config.java @@ -286,7 +286,7 @@ public class Config public static boolean AUTO_LOOT_SLOT_LIMIT; public static int LOOT_RAIDS_PRIVILEGE_INTERVAL; public static int LOOT_RAIDS_PRIVILEGE_CC_SIZE; - public static List AUTO_LOOT_ITEM_IDS; + public static Set AUTO_LOOT_ITEM_IDS; public static boolean ENABLE_KEYBOARD_MOVEMENT; public static int UNSTUCK_INTERVAL; public static int TELEPORT_WATCHDOG_TIMEOUT; @@ -476,7 +476,7 @@ public class Config public static boolean ALLOW_DISCARDITEM; public static int AUTODESTROY_ITEM_AFTER; public static int HERB_AUTO_DESTROY_TIME; - public static List LIST_PROTECTED_ITEMS; + public static Set LIST_PROTECTED_ITEMS; public static boolean DATABASE_CLEAN_UP; public static int CHAR_DATA_STORE_INTERVAL; public static int CLAN_VARIABLES_STORE_INTERVAL; @@ -567,7 +567,7 @@ public class Config public static boolean ALT_OLY_LOG_FIGHTS; public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS; public static boolean ALT_OLY_ANNOUNCE_GAMES; - public static List LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(); + public static Set LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(); public static int ALT_OLY_WEAPON_ENCHANT_LIMIT; public static int ALT_OLY_ARMOR_ENCHANT_LIMIT; public static int ALT_OLY_WAIT_TIME; @@ -1171,9 +1171,9 @@ public class Config public static int AUTO_CP_PERCENTAGE; public static int AUTO_HP_PERCENTAGE; public static int AUTO_MP_PERCENTAGE; - public static List AUTO_CP_ITEM_IDS; - public static List AUTO_HP_ITEM_IDS; - public static List AUTO_MP_ITEM_IDS; + public static Set AUTO_CP_ITEM_IDS; + public static Set AUTO_HP_ITEM_IDS; + public static Set AUTO_MP_ITEM_IDS; public static boolean CUSTOM_STARTING_LOC; public static int CUSTOM_STARTING_LOC_X; public static int CUSTOM_STARTING_LOC_Y; @@ -1183,7 +1183,7 @@ public class Config public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; public static int MOB_MIN_SPAWN_RANGE; public static int MOB_MAX_SPAWN_RANGE; - public static List MOBS_LIST_NOT_RANDOM; + public static Set MOBS_LIST_NOT_RANDOM; public static boolean FREE_JUMPS_FOR_ALL; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; @@ -1202,7 +1202,7 @@ public class Config public static boolean COMMUNITY_PREMIUM_SYSTEM_ENABLED; public static int COMMUNITY_PREMIUM_COIN_ID; public static int COMMUNITY_PREMIUM_PRICE_PER_DAY; - public static List COMMUNITY_AVAILABLE_BUFFS; + public static Set COMMUNITY_AVAILABLE_BUFFS; public static Map COMMUNITY_AVAILABLE_TELEPORTS; public static boolean CUSTOM_DEPOSITABLE_ENABLED; public static boolean CUSTOM_DEPOSITABLE_QUEST_ITEMS; @@ -1854,7 +1854,7 @@ public class Config LOOT_RAIDS_PRIVILEGE_INTERVAL = characterConfig.getInt("RaidLootRightsInterval", 900) * 1000; LOOT_RAIDS_PRIVILEGE_CC_SIZE = characterConfig.getInt("RaidLootRightsCCSize", 45); final String[] autoLootItemIds = characterConfig.getString("AutoLootItemIds", "0").split(","); - AUTO_LOOT_ITEM_IDS = new ArrayList<>(autoLootItemIds.length); + AUTO_LOOT_ITEM_IDS = new HashSet<>(autoLootItemIds.length); for (String item : autoLootItemIds) { Integer itm = 0; @@ -2008,7 +2008,7 @@ public class Config AUTODESTROY_ITEM_AFTER = generalConfig.getInt("AutoDestroyDroppedItemAfter", 600); HERB_AUTO_DESTROY_TIME = generalConfig.getInt("AutoDestroyHerbTime", 60) * 1000; final String[] split = generalConfig.getString("ListOfProtectedItems", "0").split(","); - LIST_PROTECTED_ITEMS = new ArrayList<>(split.length); + LIST_PROTECTED_ITEMS = new HashSet<>(split.length); for (String id : split) { LIST_PROTECTED_ITEMS.add(Integer.parseInt(id)); @@ -2407,7 +2407,7 @@ public class Config if (!olyRestrictedItems.isEmpty()) { final String[] olyRestrictedItemsSplit = olyRestrictedItems.split(","); - LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(olyRestrictedItemsSplit.length); + LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(olyRestrictedItemsSplit.length); for (String id : olyRestrictedItemsSplit) { LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id)); @@ -2521,17 +2521,17 @@ public class Config AUTO_CP_PERCENTAGE = autoPotionsConfig.getInt("AutoCpPercentage", 70); AUTO_HP_PERCENTAGE = autoPotionsConfig.getInt("AutoHpPercentage", 70); AUTO_MP_PERCENTAGE = autoPotionsConfig.getInt("AutoMpPercentage", 70); - AUTO_CP_ITEM_IDS = new ArrayList<>(); + AUTO_CP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoCpItemIds", "0").split(",")) { AUTO_CP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_HP_ITEM_IDS = new ArrayList<>(); + AUTO_HP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoHpItemIds", "0").split(",")) { AUTO_HP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_MP_ITEM_IDS = new ArrayList<>(); + AUTO_MP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoMpItemIds", "0").split(",")) { AUTO_MP_ITEM_IDS.add(Integer.parseInt(s)); @@ -3141,7 +3141,7 @@ public class Config COMMUNITY_PREMIUM_COIN_ID = communityBoardConfig.getInt("CommunityPremiumBuyCoinId", 57); COMMUNITY_PREMIUM_PRICE_PER_DAY = communityBoardConfig.getInt("CommunityPremiumPricePerDay", 1000000); final String[] allowedBuffs = communityBoardConfig.getString("CommunityAvailableBuffs", "").split(","); - COMMUNITY_AVAILABLE_BUFFS = new ArrayList<>(allowedBuffs.length); + COMMUNITY_AVAILABLE_BUFFS = new HashSet<>(allowedBuffs.length); for (String s : allowedBuffs) { COMMUNITY_AVAILABLE_BUFFS.add(Integer.parseInt(s)); @@ -3428,7 +3428,7 @@ public class Config if (ENABLE_RANDOM_MONSTER_SPAWNS) { final String[] mobsIds = randomSpawnsConfig.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); - MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + MOBS_LIST_NOT_RANDOM = new HashSet<>(mobsIds.length); for (String id : mobsIds) { MOBS_LIST_NOT_RANDOM.add(Integer.parseInt(id)); diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java index d6e0183c6f..c3977185b4 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java @@ -202,8 +202,7 @@ public class ClanHallData implements IXmlReader final Door door = DoorData.getInstance().getDoor(doorId); for (ClanHall ch : _clanHalls.values()) { - final List doors = ch.getDoors(); - if ((doors != null) && doors.contains(door)) + if (ch.getDoors().contains(door)) { return ch; } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java index 6aa0a1fdde..fb395b9e2d 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java @@ -17,10 +17,10 @@ package org.l2jmobius.gameserver.data.xml; import java.io.File; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -42,7 +42,7 @@ public class FakePlayerData implements IXmlReader private final Map _fakePlayerInfos = new HashMap<>(); private final Map _fakePlayerNames = new HashMap<>(); private final Map _fakePlayerIds = new HashMap<>(); - private final List _talkableFakePlayerNames = new ArrayList<>(); + private final Set _talkableFakePlayerNames = new HashSet<>(); protected FakePlayerData() { diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java index d335b95954..1122d7b9ba 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java @@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -49,7 +51,7 @@ import org.l2jmobius.gameserver.util.Util; public class SellBuffsManager implements IXmlReader { private static final Logger LOGGER = Logger.getLogger(SellBuffsManager.class.getName()); - private static final List ALLOWED_BUFFS = new ArrayList<>(); + private static final Set ALLOWED_BUFFS = new HashSet<>(); private static final String HTML_FOLDER = "data/html/mods/SellBuffs/"; protected SellBuffsManager() @@ -76,11 +78,7 @@ public class SellBuffsManager implements IXmlReader { final Element elem = (Element) node.item(i); final int skillId = Integer.parseInt(elem.getAttribute("id")); - - if (!ALLOWED_BUFFS.contains(skillId)) - { - ALLOWED_BUFFS.add(skillId); - } + ALLOWED_BUFFS.add(skillId); } } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java index b10f75ef3d..1e45a21319 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java @@ -19,8 +19,10 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; @@ -67,7 +69,7 @@ public class WalkingManager implements IXmlReader public static final byte REPEAT_TELE_FIRST = 2; public static final byte REPEAT_RANDOM = 3; - private final List _targetedNpcIds = new ArrayList<>(); + private final Set _targetedNpcIds = new HashSet<>(); private final Map _routes = new HashMap<>(); // all available routes private final Map _activeRoutes = new HashMap<>(); // each record represents NPC, moving by predefined route from _routes, and moving progress private final Map _routesToAttach = new HashMap<>(); // each record represents NPC and all available routes for it diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/BlockList.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/BlockList.java index 1af9941ed5..9ac6266e22 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/BlockList.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/BlockList.java @@ -19,9 +19,9 @@ package org.l2jmobius.gameserver.model; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -36,10 +36,11 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; public class BlockList { private static final Logger LOGGER = Logger.getLogger(BlockList.class.getName()); - private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); + + private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); private final Player _owner; - private List _blockList; + private Set _blockList; public BlockList(Player owner) { @@ -68,9 +69,9 @@ public class BlockList OFFLINE_LIST.put(_owner.getObjectId(), _blockList); } - private static List loadList(int objId) + private static Set loadList(int objId) { - final List list = new ArrayList<>(); + final Set list = new HashSet<>(); try (Connection con = DatabaseFactory.getConnection(); PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1")) { @@ -158,7 +159,7 @@ public class BlockList _owner.setMessageRefusal(value); } - private List getBlockList() + private Set getBlockList() { return _blockList; } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/PetData.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/PetData.java index b534c21f36..231b85e85f 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/PetData.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/PetData.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; import org.l2jmobius.gameserver.model.holders.SkillHolder; @@ -40,7 +42,7 @@ public class PetData private int _minLevel = Byte.MAX_VALUE; private int _maxLevel = 0; private boolean _syncLevel = false; - private final List _food = new ArrayList<>(); + private final Set _food = new HashSet<>(); public PetData(int npcId, int itemId) { @@ -133,7 +135,7 @@ public class PetData /** * @return the pet's food list. */ - public List getFood() + public Set getFood() { return _food; } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/SkillLearn.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/SkillLearn.java index a69d30f105..3d5704b5f2 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/SkillLearn.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/SkillLearn.java @@ -16,9 +16,8 @@ */ package org.l2jmobius.gameserver.model; -import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashSet; -import java.util.List; import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -40,12 +39,12 @@ public class SkillLearn private final int _getDualClassLevel; private final boolean _autoGet; private final long _levelUpSp; - private final List _requiredItems = new ArrayList<>(); - private final List _races = new ArrayList<>(); - private final List _preReqSkills = new ArrayList<>(); + private final Set _requiredItems = new HashSet<>(1); + private final Set _races = EnumSet.noneOf(Race.class); + private final Set _preReqSkills = new HashSet<>(1); private SocialClass _socialClass; private final boolean _residenceSkill; - private final List _residenceIds = new ArrayList<>(); + private final Set _residenceIds = new HashSet<>(1); private final boolean _learnedByNpc; private final boolean _learnedByFS; private final Set _removeSkills = new HashSet<>(1); @@ -133,9 +132,9 @@ public class SkillLearn } /** - * @return the list with the item holders required to acquire this skill. + * @return the set with the item holders required to acquire this skill. */ - public List getRequiredItems() + public Set getRequiredItems() { return _requiredItems; } @@ -150,9 +149,9 @@ public class SkillLearn } /** - * @return a list with the races that can acquire this skill. + * @return a set with the races that can acquire this skill. */ - public List getRaces() + public Set getRaces() { return _races; } @@ -167,9 +166,9 @@ public class SkillLearn } /** - * @return the list of skill holders required to acquire this skill. + * @return the set of skill holders required to acquire this skill. */ - public List getPreReqSkills() + public Set getPreReqSkills() { return _preReqSkills; } @@ -212,9 +211,9 @@ public class SkillLearn } /** - * @return a list with the Ids where this skill is available. + * @return a set with the Ids where this skill is available. */ - public List getResidenceIds() + public Set getResidenceIds() { return _residenceIds; } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java index 76d810a2d9..3b04eafa72 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java @@ -22,7 +22,6 @@ import java.sql.ResultSet; import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.List; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; @@ -153,7 +152,7 @@ public class Pet extends Summon broadcastStatusUpdate(); - final List foodIds = getPetData().getFood(); + final Set foodIds = getPetData().getFood(); if (foodIds.isEmpty()) { if (isUncontrollable()) diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java index ddd5c20f5c..650e0257d2 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java @@ -16,8 +16,8 @@ */ package org.l2jmobius.gameserver.model.actor.instance; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import org.l2jmobius.commons.threads.ThreadPool; @@ -57,7 +57,7 @@ public class Trap extends Npc private boolean _isTriggered; private final int _lifeTime; private Player _owner; - private final List _playersWhoDetectedMe = new ArrayList<>(); + private final Set _playersWhoDetectedMe = new HashSet<>(); private final SkillHolder _skill; private int _remainingTime; // Tasks diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java index 71ef076212..3ba8c20a9b 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor.tasks.player; -import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -69,11 +69,12 @@ public class PetFeedTask implements Runnable _player.sendPacket(SystemMessageId.YOU_ARE_OUT_OF_FEED_MOUNT_STATUS_CANCELED); } - final List foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); + final Set foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); if (foodIds.isEmpty()) { return; } + Item food = null; for (int id : foodIds) { diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java index 50d2a821c3..2611b5f121 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.actor.Creature; @@ -29,9 +29,9 @@ import org.l2jmobius.gameserver.model.zone.ZoneType; */ public class ConditionPlayerInsideZoneId extends Condition { - private final List _zones; + private final Set _zones; - public ConditionPlayerInsideZoneId(List zones) + public ConditionPlayerInsideZoneId(Set zones) { _zones = zones; } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java index c15065eca2..d644f663f5 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Player; @@ -29,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerInstanceId extends Condition { - private final List _instanceIds; + private final Set _instanceIds; /** * Instantiates a new condition player instance id. * @param instanceIds the instance ids */ - public ConditionPlayerInstanceId(List instanceIds) + public ConditionPlayerInstanceId(Set instanceIds) { _instanceIds = instanceIds; } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java index 14d61089ed..7c375ec45e 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -28,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerRace extends Condition { - private final Race[] _races; + private final Set _races; /** * Instantiates a new condition player race. * @param races the list containing the allowed races. */ - public ConditionPlayerRace(Race[] races) + public ConditionPlayerRace(Set races) { _races = races; } @@ -46,6 +47,6 @@ public class ConditionPlayerRace extends Condition { return false; } - return CommonUtil.contains(_races, effector.getActingPlayer().getRace()); + return _races.contains(effector.getActingPlayer().getRace()); } } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java index 0f54766571..0b326e3f40 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId())) + if (_npcIds.contains(target.getId())) { existNpc = true; break; diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java index c5c9b5ff0e..db64b6bd7b 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromSummonedNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromSummonedNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromSummonedNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromSummonedNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId()) && (effector == target.getSummoner())) + if (_npcIds.contains(target.getId()) && (effector == target.getSummoner())) { existNpc = true; break; diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java index a3fb0f5374..a47b4b4983 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetClassIdRestriction extends Condition { - private final List _classIds; + private final Set _classIds; /** * Instantiates a new condition target class id restriction. * @param classId the class id */ - public ConditionTargetClassIdRestriction(List classId) + public ConditionTargetClassIdRestriction(Set classId) { _classIds = classId; } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java index 82b1bd5877..9bb694f4ef 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetNpcId extends Condition { - private final List _npcIds; + private final Set _npcIds; /** * Instantiates a new condition target npc id. * @param npcIds the npc ids */ - public ConditionTargetNpcId(List npcIds) + public ConditionTargetNpcId(Set npcIds) { _npcIds = npcIds; } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java index f26329bc21..5c86f26ae5 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.holders; -import java.util.Collection; +import java.util.Set; /** * @author Mobius @@ -25,9 +25,9 @@ public class EventDropHolder extends DropHolder { private final int _minLevel; private final int _maxLevel; - private final Collection _monsterIds; + private final Set _monsterIds; - public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Collection monsterIds) + public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Set monsterIds) { super(null, itemId, min, max, chance); _minLevel = minLevel; @@ -45,7 +45,7 @@ public class EventDropHolder extends DropHolder return _maxLevel; } - public Collection getMonsterIds() + public Set getMonsterIds() { return _monsterIds; } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/item/Henna.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/item/Henna.java index 107656dba9..3fa8d06bc6 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/item/Henna.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/item/Henna.java @@ -17,9 +17,11 @@ package org.l2jmobius.gameserver.model.item; import java.util.ArrayList; -import java.util.HashMap; +import java.util.EnumMap; +import java.util.EnumSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.enums.ClassId; import org.l2jmobius.gameserver.model.StatSet; @@ -34,14 +36,14 @@ public class Henna { private final int _dyeId; private final int _dyeItemId; - private final Map _baseStats = new HashMap<>(); + private final Map _baseStats = new EnumMap<>(BaseStat.class); private final int _wearFee; private final int _wearCount; private final int _cancelFee; private final int _cancelCount; private final int _duration; private final List _skills; - private final List _wearClass; + private final Set _wearClass; public Henna(StatSet set) { @@ -59,7 +61,7 @@ public class Henna _cancelCount = set.getInt("cancel_count"); _duration = set.getInt("duration", -1); _skills = new ArrayList<>(); - _wearClass = new ArrayList<>(); + _wearClass = EnumSet.noneOf(ClassId.class); } /** @@ -147,7 +149,7 @@ public class Henna /** * @return the list with the allowed classes to wear this dye. */ - public List getAllowedWearClass() + public Set getAllowedWearClass() { return _wearClass; } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java index d74b1218d3..5d694e5169 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java @@ -17,9 +17,10 @@ package org.l2jmobius.gameserver.model.item.appearance; import java.time.Duration; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.enums.Race; @@ -47,12 +48,12 @@ public class AppearanceStone private final ArmorType _armorType; private final AppearanceHandType _handType; private final AppearanceMagicType _magicType; - private List _crystalTypes; - private List _targetTypes; - private List _bodyParts; - private List _races; - private List _racesNot; - private List _allVisualIds; + private Set _crystalTypes; + private Set _targetTypes; + private Set _bodyParts; + private Set _races; + private Set _racesNot; + private Set _allVisualIds; public AppearanceStone(StatSet set) { @@ -172,35 +173,35 @@ public class AppearanceStone { if (_crystalTypes == null) { - _crystalTypes = new ArrayList<>(); + _crystalTypes = EnumSet.noneOf(CrystalType.class); } _crystalTypes.add(type); } - public List getCrystalTypes() + public Set getCrystalTypes() { - return _crystalTypes != null ? _crystalTypes : Collections.emptyList(); + return _crystalTypes != null ? _crystalTypes : Collections.emptySet(); } public void addTargetType(AppearanceTargetType type) { if (_targetTypes == null) { - _targetTypes = new ArrayList<>(); + _targetTypes = EnumSet.noneOf(AppearanceTargetType.class); } _targetTypes.add(type); } - public List getTargetTypes() + public Set getTargetTypes() { - return _targetTypes != null ? _targetTypes : Collections.emptyList(); + return _targetTypes != null ? _targetTypes : Collections.emptySet(); } public void addBodyPart(long part) { if (_bodyParts == null) { - _bodyParts = new ArrayList<>(); + _bodyParts = new HashSet<>(); } _bodyParts.add(part); } @@ -209,47 +210,47 @@ public class AppearanceStone { if (_allVisualIds == null) { - _allVisualIds = new ArrayList<>(); + _allVisualIds = new HashSet<>(); } _allVisualIds.add(appearanceHolder); } - public List getVisualIds() + public Set getVisualIds() { - return _allVisualIds != null ? _allVisualIds : Collections.emptyList(); + return _allVisualIds != null ? _allVisualIds : Collections.emptySet(); } - public List getBodyParts() + public Set getBodyParts() { - return _bodyParts != null ? _bodyParts : Collections.emptyList(); + return _bodyParts != null ? _bodyParts : Collections.emptySet(); } public void addRace(Race race) { if (_races == null) { - _races = new ArrayList<>(); + _races = EnumSet.noneOf(Race.class); } _races.add(race); } - public List getRaces() + public Set getRaces() { - return _races != null ? _races : Collections.emptyList(); + return _races != null ? _races : Collections.emptySet(); } public void addRaceNot(Race race) { if (_racesNot == null) { - _racesNot = new ArrayList<>(); + _racesNot = EnumSet.noneOf(Race.class); } _racesNot.add(race); } - public List getRacesNot() + public Set getRacesNot() { - return _racesNot != null ? _racesNot : Collections.emptyList(); + return _racesNot != null ? _racesNot : Collections.emptySet(); } /** @@ -302,7 +303,7 @@ public class AppearanceStone { // Seems like in retail item with already changed appearance, can be changed again without being restored. - final AppearanceTargetType targetType = getTargetTypes().get(0); + final AppearanceTargetType targetType = getTargetTypes().stream().findFirst().get(); switch (targetType) { case NONE: diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java index 5d3a79d524..5e067a67e5 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java @@ -16,16 +16,16 @@ */ package org.l2jmobius.gameserver.model.item.enchant; +import java.util.EnumSet; +import java.util.Set; import java.util.logging.Logger; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.item.ItemTemplate; import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.model.item.type.CrystalType; import org.l2jmobius.gameserver.model.item.type.EtcItemType; -import org.l2jmobius.gameserver.model.item.type.ItemType; /** * @author UnAfraid @@ -34,26 +34,27 @@ public abstract class AbstractEnchantItem { protected static final Logger LOGGER = Logger.getLogger(AbstractEnchantItem.class.getName()); - private static final ItemType[] ENCHANT_TYPES = new ItemType[] + private static final Set ENCHANT_TYPES = EnumSet.noneOf(EtcItemType.class); + static { - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM, - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP, - EtcItemType.BLESS_ENCHT_AM, - EtcItemType.BLESS_ENCHT_AM_DOWN, - EtcItemType.BLESS_ENCHT_WP, - EtcItemType.ENCHT_AM, - EtcItemType.ENCHT_WP, - EtcItemType.GIANT_ENCHT_AM, - EtcItemType.GIANT_ENCHT_WP, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - }; + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + } private final int _id; private final CrystalType _grade; @@ -71,7 +72,7 @@ public abstract class AbstractEnchantItem { throw new NullPointerException(); } - else if (!CommonUtil.contains(ENCHANT_TYPES, getItem().getItemType())) + else if (!ENCHANT_TYPES.contains(getItem().getItemType())) { throw new IllegalAccessError(); } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java index 5ba6755084..18508d0145 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java @@ -24,8 +24,10 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Set; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -184,7 +186,7 @@ public class LongTimeEvent extends Quest final Node maxLevelNode = d.getAttributes().getNamedItem("maxLevel"); final int maxLevel = maxLevelNode == null ? Integer.MAX_VALUE : Integer.parseInt(maxLevelNode.getNodeValue()); final Node monsterIdsNode = d.getAttributes().getNamedItem("monsterIds"); - final List monsterIds = new ArrayList<>(); + final Set monsterIds = new HashSet<>(); if (monsterIdsNode != null) { for (String id : monsterIdsNode.getNodeValue().split(",")) diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/residences/ClanHall.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/residences/ClanHall.java index 0c0a529077..fcc850371b 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/residences/ClanHall.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/residences/ClanHall.java @@ -23,7 +23,9 @@ import java.sql.SQLException; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -61,9 +63,9 @@ public class ClanHall extends AbstractResidence private final int _minBid; final int _lease; private final int _deposit; - private final List _npcs; - private final List _doors; - private final List _teleports; + private final Set _npcs = new HashSet<>(); + private final Set _doors = new HashSet<>(); + private final Set _teleports = new HashSet<>(); private final Location _ownerLocation; private final Location _banishLocation; // Dynamic parameters @@ -85,9 +87,21 @@ public class ClanHall extends AbstractResidence _minBid = params.getInt("minBid"); _lease = params.getInt("lease"); _deposit = params.getInt("deposit"); - _npcs = params.getList("npcList", Integer.class); - _doors = params.getList("doorList", Door.class); - _teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + final List npcs = params.getList("npcList", Integer.class); + if (npcs != null) + { + _npcs.addAll(npcs); + } + final List doors = params.getList("doorList", Door.class); + if (doors != null) + { + _doors.addAll(doors); + } + final List teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + if (teleports != null) + { + _teleports.addAll(teleports); + } _ownerLocation = params.getLocation("owner_loc"); _banishLocation = params.getLocation("banish_loc"); // Set dynamic parameters (from DB) @@ -196,7 +210,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Door} related to this {@link ClanHall}. * @return all {@link Door} related to this {@link ClanHall} */ - public List getDoors() + public Set getDoors() { return _doors; } @@ -205,7 +219,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Npc} related to this {@link ClanHall}. * @return all {@link Npc} related to this {@link ClanHall} */ - public List getNpcs() + public Set getNpcs() { return _npcs; } @@ -324,7 +338,7 @@ public class ClanHall extends AbstractResidence return _banishLocation; } - public List getTeleportList() + public Set getTeleportList() { return _teleports; } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/siege/Castle.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/siege/Castle.java index d053196bec..4e90413baf 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/siege/Castle.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/siege/Castle.java @@ -21,8 +21,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.Calendar; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -83,7 +85,7 @@ public class Castle extends AbstractResidence private SiegeZone _zone = null; private ResidenceTeleportZone _teleZone; private Clan _formerOwner = null; - private final List _artefacts = new ArrayList<>(1); + private final Set _artefacts = new HashSet<>(1); private final Map _function = new ConcurrentHashMap<>(); private int _ticketBuyCount = 0; private boolean _isFirstMidVictory = false; @@ -1072,7 +1074,7 @@ public class Castle extends AbstractResidence _artefacts.add(artefact); } - public List getArtefacts() + public Set getArtefacts() { return _artefacts; } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java index 0c79677eae..4ebf954ee5 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.network.serverpackets; -import java.util.List; +import java.util.Set; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.gameserver.data.sql.CharNameTable; @@ -27,19 +27,19 @@ import org.l2jmobius.gameserver.network.OutgoingPackets; */ public class BlockListPacket implements IClientOutgoingPacket { - private final List _playersId; + private final Set _playerIds; - public BlockListPacket(List playersId) + public BlockListPacket(Set playerIds) { - _playersId = playersId; + _playerIds = playerIds; } @Override public boolean write(PacketWriter packet) { OutgoingPackets.BLOCK_LIST.writeId(packet); - packet.writeD(_playersId.size()); - for (int playerId : _playersId) + packet.writeD(_playerIds.size()); + for (int playerId : _playerIds) { packet.writeS(CharNameTable.getInstance().getNameById(playerId)); packet.writeS(""); // memo ? diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java index 8555bb6e86..eb5bfd05d8 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.network.serverpackets; import java.util.List; import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; import org.l2jmobius.commons.network.PacketWriter; @@ -37,7 +38,7 @@ public class ExAcquireSkillInfo implements IClientOutgoingPacket private final int _dualClassLevel; private final long _spCost; private final int _minLevel; - private final List _itemReq; + private final Set _itemReq; private final List _skillRem; /** diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java index 84b5fead76..a163a85735 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java @@ -35,7 +35,7 @@ public class ExChooseShapeShiftingItem implements IClientOutgoingPacket public ExChooseShapeShiftingItem(AppearanceStone stone) { _type = stone.getType(); - _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().get(0); + _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().stream().findFirst().get(); _itemId = stone.getId(); } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/DocumentBase.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/DocumentBase.java index 28bfbc316c..2ffccdc2ac 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/DocumentBase.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/DocumentBase.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.util; import java.io.File; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -391,12 +392,12 @@ public abstract class DocumentBase case "races": { final String[] racesVal = a.getNodeValue().split(","); - final Race[] races = new Race[racesVal.length]; + final Set races = EnumSet.noneOf(Race.class); for (int r = 0; r < racesVal.length; r++) { if (racesVal[r] != null) { - races[r] = Race.valueOf(racesVal[r]); + races.add(Race.valueOf(racesVal[r])); } } cond = joinAnd(cond, new ConditionPlayerRace(races)); @@ -673,13 +674,13 @@ public abstract class DocumentBase case "instanceid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final ArrayList array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInstanceId(array)); + cond = joinAnd(cond, new ConditionPlayerInstanceId(set)); break; } case "agathionid": @@ -730,10 +731,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -747,10 +748,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -836,13 +837,13 @@ public abstract class DocumentBase case "insidezoneid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInsideZoneId(array)); + cond = joinAnd(cond, new ConditionPlayerInsideZoneId(set)); break; } case "checkabnormal": @@ -963,13 +964,13 @@ public abstract class DocumentBase case "class_id_restriction": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetClassIdRestriction(array)); + cond = joinAnd(cond, new ConditionTargetClassIdRestriction(set)); break; } case "active_effect_id": @@ -1047,13 +1048,13 @@ public abstract class DocumentBase case "npcid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetNpcId(array)); + cond = joinAnd(cond, new ConditionTargetNpcId(set)); break; } case "npctype": diff --git a/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/bypasshandlers/Link.java b/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/bypasshandlers/Link.java index e73fc8216a..61fa84b6ea 100644 --- a/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/bypasshandlers/Link.java +++ b/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/bypasshandlers/Link.java @@ -16,7 +16,9 @@ */ package handlers.bypasshandlers; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.HashSet; +import java.util.Set; + import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.handler.IBypassHandler; import org.l2jmobius.gameserver.model.actor.Creature; @@ -31,32 +33,33 @@ public class Link implements IBypassHandler "Link" }; - private static final String[] VALID_LINKS = + private static final Set VALID_LINKS = new HashSet<>(); + static { - "common/craft_01.htm", - "common/craft_02.htm", - "common/skill_enchant_help_01.htm", - "common/skill_enchant_help_02.htm", - "common/skill_enchant_help_03.htm", - "common/weapon_sa_01.htm", - "default/BlessingOfProtection.htm", - "default/SupportMagic.htm", - "fisherman/exchange_old_items.htm", - "fisherman/fish_appearance_exchange.htm", - "fisherman/fishing_manual001.htm", - "fisherman/fishing_manual002.htm", - "fisherman/fishing_manual003.htm", - "fisherman/fishing_manual004.htm", - "fisherman/fishing_manual008.htm", - "fisherman/fishing_manual009.htm", - "fisherman/fishing_manual010.htm", - "fortress/foreman.htm", - "petmanager/evolve.htm", - "petmanager/exchange.htm", - "petmanager/instructions.htm", - "warehouse/clanwh.htm", - "warehouse/privatewh.htm", - }; + VALID_LINKS.add("common/craft_01.htm"); + VALID_LINKS.add("common/craft_02.htm"); + VALID_LINKS.add("common/skill_enchant_help_01.htm"); + VALID_LINKS.add("common/skill_enchant_help_02.htm"); + VALID_LINKS.add("common/skill_enchant_help_03.htm"); + VALID_LINKS.add("common/weapon_sa_01.htm"); + VALID_LINKS.add("default/BlessingOfProtection.htm"); + VALID_LINKS.add("default/SupportMagic.htm"); + VALID_LINKS.add("fisherman/exchange_old_items.htm"); + VALID_LINKS.add("fisherman/fish_appearance_exchange.htm"); + VALID_LINKS.add("fisherman/fishing_manual001.htm"); + VALID_LINKS.add("fisherman/fishing_manual002.htm"); + VALID_LINKS.add("fisherman/fishing_manual003.htm"); + VALID_LINKS.add("fisherman/fishing_manual004.htm"); + VALID_LINKS.add("fisherman/fishing_manual008.htm"); + VALID_LINKS.add("fisherman/fishing_manual009.htm"); + VALID_LINKS.add("fisherman/fishing_manual010.htm"); + VALID_LINKS.add("fortress/foreman.htm"); + VALID_LINKS.add("petmanager/evolve.htm"); + VALID_LINKS.add("petmanager/exchange.htm"); + VALID_LINKS.add("petmanager/instructions.htm"); + VALID_LINKS.add("warehouse/clanwh.htm"); + VALID_LINKS.add("warehouse/privatewh.htm"); + } @Override public boolean useBypass(String command, Player player, Creature target) @@ -74,12 +77,13 @@ public class Link implements IBypassHandler return false; } - String content = CommonUtil.contains(VALID_LINKS, htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; + String content = VALID_LINKS.contains(htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; // Precaution. if (htmlPath.startsWith("teleporter/") && !(player.getTarget() instanceof Teleporter)) { content = null; } + final NpcHtmlMessage html = new NpcHtmlMessage(target != null ? target.getObjectId() : 0); if (content != null) { diff --git a/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/itemhandlers/PetFood.java b/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/itemhandlers/PetFood.java index 3c5572d4ec..8b908ea095 100644 --- a/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/itemhandlers/PetFood.java +++ b/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/itemhandlers/PetFood.java @@ -17,6 +17,7 @@ package handlers.itemhandlers; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.PetDataTable; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -79,7 +80,7 @@ public class PetFood implements IItemHandler final Player player = activeChar.getActingPlayer(); if (player.isMounted()) { - final List foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); + final Set foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); if (foodIds.contains(item.getId()) && player.destroyItem("Consume", item.getObjectId(), 1, null, false)) { player.broadcastPacket(new MagicSkillUse(player, player, skillId, skillLevel, 0, 0)); diff --git a/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java b/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java index 2ad282f683..99f45fbb41 100644 --- a/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java +++ b/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.ClanHallData; import org.l2jmobius.gameserver.model.StatSet; @@ -32,12 +33,12 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpCheckResidenceSkillCondition implements ISkillCondition { - private final List _residencesId; + private final Set _residencesId = new HashSet<>(); private final boolean _isWithin; public OpCheckResidenceSkillCondition(StatSet params) { - _residencesId = params.getList("residencesId", Integer.class); + _residencesId.addAll(params.getList("residencesId", Integer.class)); _isWithin = params.getBoolean("isWithin"); } diff --git a/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java b/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java index fc2934423b..4a8282d988 100644 --- a/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java +++ b/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java @@ -16,9 +16,9 @@ */ package handlers.skillconditionhandlers; -import java.util.ArrayList; -import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -28,18 +28,18 @@ import org.l2jmobius.gameserver.model.skill.ISkillCondition; import org.l2jmobius.gameserver.model.skill.Skill; /** - * @author UnAfraid + * @author UnAfraid, Mobius */ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition { - private final List _npcIds = new ArrayList<>(); + private final Set _npcIds = new HashSet<>(); public OpNeedSummonOrPetSkillCondition(StatSet params) { - final List npcIds = params.getList("npcIds", String.class); + final List npcIds = params.getList("npcIds", Integer.class); if (npcIds != null) { - npcIds.stream().map(Integer::valueOf).forEach(_npcIds::add); + _npcIds.addAll(npcIds); } } @@ -47,7 +47,19 @@ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition public boolean canUse(Creature caster, Skill skill, WorldObject target) { final Summon pet = caster.getPet(); - final Collection summons = caster.getServitors().values(); - return ((pet != null) && _npcIds.stream().anyMatch(npcId -> npcId == pet.getId())) || summons.stream().anyMatch(summon -> _npcIds.contains(summon.getId())); + if ((pet != null) && _npcIds.contains(pet.getId())) + { + return true; + } + + for (Summon summon : caster.getServitors().values()) + { + if (_npcIds.contains(summon.getId())) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java b/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java index 8541bc62b4..ef81b291d4 100644 --- a/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java +++ b/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,11 +30,11 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetDoorSkillCondition implements ISkillCondition { - private final List _doorIds; + private final Set _doorIds = new HashSet<>(); public OpTargetDoorSkillCondition(StatSet params) { - _doorIds = params.getList("doorIds", Integer.class); + _doorIds.addAll(params.getList("doorIds", Integer.class)); } @Override diff --git a/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java b/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java index 3ce4145703..0ccd571e19 100644 --- a/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java +++ b/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,17 +30,17 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetNpcSkillCondition implements ISkillCondition { - private final List _npcId; + private final Set _npcIds = new HashSet<>(); public OpTargetNpcSkillCondition(StatSet params) { - _npcId = params.getList("npcIds", Integer.class); + _npcIds.addAll(params.getList("npcIds", Integer.class)); } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget(); - return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId()); + return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcIds.contains(actualTarget.getId()); } } diff --git a/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/instances/AbstractInstance.java b/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/instances/AbstractInstance.java index 94c337f0df..a5b4ef238a 100644 --- a/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/instances/AbstractInstance.java +++ b/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/instances/AbstractInstance.java @@ -16,9 +16,10 @@ */ package instances; +import java.util.HashSet; import java.util.List; +import java.util.Set; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.enums.InstanceReenterType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.instancemanager.InstanceManager; @@ -40,25 +41,29 @@ import ai.AbstractNpcAI; */ public abstract class AbstractInstance extends AbstractNpcAI { - private final int[] _templateIds; + private final Set _templateIds = new HashSet<>(); - public AbstractInstance(int... templateId) + public AbstractInstance(int... templateIds) { - if (templateId.length == 0) + if (templateIds.length == 0) { throw new IllegalStateException("No template ids were provided!"); } - _templateIds = templateId; + + for (int templateId : templateIds) + { + _templateIds.add(templateId); + } } - public int[] getTemplateId() + public Set getTemplateId() { return _templateIds; } public boolean isInInstance(Instance instance) { - return (instance != null) && CommonUtil.contains(_templateIds, instance.getTemplateId()); + return (instance != null) && _templateIds.contains(instance.getTemplateId()); } /** diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/Config.java index a6392c4c9a..cf59172ffc 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/Config.java @@ -285,7 +285,7 @@ public class Config public static boolean AUTO_LOOT_SLOT_LIMIT; public static int LOOT_RAIDS_PRIVILEGE_INTERVAL; public static int LOOT_RAIDS_PRIVILEGE_CC_SIZE; - public static List AUTO_LOOT_ITEM_IDS; + public static Set AUTO_LOOT_ITEM_IDS; public static boolean ENABLE_KEYBOARD_MOVEMENT; public static int UNSTUCK_INTERVAL; public static int TELEPORT_WATCHDOG_TIMEOUT; @@ -476,7 +476,7 @@ public class Config public static boolean ALLOW_DISCARDITEM; public static int AUTODESTROY_ITEM_AFTER; public static int HERB_AUTO_DESTROY_TIME; - public static List LIST_PROTECTED_ITEMS; + public static Set LIST_PROTECTED_ITEMS; public static boolean DATABASE_CLEAN_UP; public static int CHAR_DATA_STORE_INTERVAL; public static int CLAN_VARIABLES_STORE_INTERVAL; @@ -568,7 +568,7 @@ public class Config public static boolean ALT_OLY_LOG_FIGHTS; public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS; public static boolean ALT_OLY_ANNOUNCE_GAMES; - public static List LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(); + public static Set LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(); public static int ALT_OLY_WEAPON_ENCHANT_LIMIT; public static int ALT_OLY_ARMOR_ENCHANT_LIMIT; public static int ALT_OLY_WAIT_TIME; @@ -1172,9 +1172,9 @@ public class Config public static int AUTO_CP_PERCENTAGE; public static int AUTO_HP_PERCENTAGE; public static int AUTO_MP_PERCENTAGE; - public static List AUTO_CP_ITEM_IDS; - public static List AUTO_HP_ITEM_IDS; - public static List AUTO_MP_ITEM_IDS; + public static Set AUTO_CP_ITEM_IDS; + public static Set AUTO_HP_ITEM_IDS; + public static Set AUTO_MP_ITEM_IDS; public static boolean CUSTOM_STARTING_LOC; public static int CUSTOM_STARTING_LOC_X; public static int CUSTOM_STARTING_LOC_Y; @@ -1184,7 +1184,7 @@ public class Config public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; public static int MOB_MIN_SPAWN_RANGE; public static int MOB_MAX_SPAWN_RANGE; - public static List MOBS_LIST_NOT_RANDOM; + public static Set MOBS_LIST_NOT_RANDOM; public static boolean FREE_JUMPS_FOR_ALL; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; @@ -1203,7 +1203,7 @@ public class Config public static boolean COMMUNITY_PREMIUM_SYSTEM_ENABLED; public static int COMMUNITY_PREMIUM_COIN_ID; public static int COMMUNITY_PREMIUM_PRICE_PER_DAY; - public static List COMMUNITY_AVAILABLE_BUFFS; + public static Set COMMUNITY_AVAILABLE_BUFFS; public static Map COMMUNITY_AVAILABLE_TELEPORTS; public static boolean CUSTOM_DEPOSITABLE_ENABLED; public static boolean CUSTOM_DEPOSITABLE_QUEST_ITEMS; @@ -1842,7 +1842,7 @@ public class Config LOOT_RAIDS_PRIVILEGE_INTERVAL = characterConfig.getInt("RaidLootRightsInterval", 900) * 1000; LOOT_RAIDS_PRIVILEGE_CC_SIZE = characterConfig.getInt("RaidLootRightsCCSize", 45); final String[] autoLootItemIds = characterConfig.getString("AutoLootItemIds", "0").split(","); - AUTO_LOOT_ITEM_IDS = new ArrayList<>(autoLootItemIds.length); + AUTO_LOOT_ITEM_IDS = new HashSet<>(autoLootItemIds.length); for (String item : autoLootItemIds) { Integer itm = 0; @@ -1963,7 +1963,7 @@ public class Config AUTODESTROY_ITEM_AFTER = generalConfig.getInt("AutoDestroyDroppedItemAfter", 600); HERB_AUTO_DESTROY_TIME = generalConfig.getInt("AutoDestroyHerbTime", 60) * 1000; final String[] split = generalConfig.getString("ListOfProtectedItems", "0").split(","); - LIST_PROTECTED_ITEMS = new ArrayList<>(split.length); + LIST_PROTECTED_ITEMS = new HashSet<>(split.length); for (String id : split) { LIST_PROTECTED_ITEMS.add(Integer.parseInt(id)); @@ -2364,7 +2364,7 @@ public class Config if (!olyRestrictedItems.isEmpty()) { final String[] olyRestrictedItemsSplit = olyRestrictedItems.split(","); - LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(olyRestrictedItemsSplit.length); + LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(olyRestrictedItemsSplit.length); for (String id : olyRestrictedItemsSplit) { LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id)); @@ -2481,17 +2481,17 @@ public class Config AUTO_CP_PERCENTAGE = autoPotionsConfig.getInt("AutoCpPercentage", 70); AUTO_HP_PERCENTAGE = autoPotionsConfig.getInt("AutoHpPercentage", 70); AUTO_MP_PERCENTAGE = autoPotionsConfig.getInt("AutoMpPercentage", 70); - AUTO_CP_ITEM_IDS = new ArrayList<>(); + AUTO_CP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoCpItemIds", "0").split(",")) { AUTO_CP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_HP_ITEM_IDS = new ArrayList<>(); + AUTO_HP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoHpItemIds", "0").split(",")) { AUTO_HP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_MP_ITEM_IDS = new ArrayList<>(); + AUTO_MP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoMpItemIds", "0").split(",")) { AUTO_MP_ITEM_IDS.add(Integer.parseInt(s)); @@ -3101,7 +3101,7 @@ public class Config COMMUNITY_PREMIUM_COIN_ID = communityBoardConfig.getInt("CommunityPremiumBuyCoinId", 57); COMMUNITY_PREMIUM_PRICE_PER_DAY = communityBoardConfig.getInt("CommunityPremiumPricePerDay", 1000000); final String[] allowedBuffs = communityBoardConfig.getString("CommunityAvailableBuffs", "").split(","); - COMMUNITY_AVAILABLE_BUFFS = new ArrayList<>(allowedBuffs.length); + COMMUNITY_AVAILABLE_BUFFS = new HashSet<>(allowedBuffs.length); for (String s : allowedBuffs) { COMMUNITY_AVAILABLE_BUFFS.add(Integer.parseInt(s)); @@ -3404,7 +3404,7 @@ public class Config if (ENABLE_RANDOM_MONSTER_SPAWNS) { final String[] mobsIds = randomSpawnsConfig.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); - MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + MOBS_LIST_NOT_RANDOM = new HashSet<>(mobsIds.length); for (String id : mobsIds) { MOBS_LIST_NOT_RANDOM.add(Integer.parseInt(id)); diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java index d6e0183c6f..c3977185b4 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java @@ -202,8 +202,7 @@ public class ClanHallData implements IXmlReader final Door door = DoorData.getInstance().getDoor(doorId); for (ClanHall ch : _clanHalls.values()) { - final List doors = ch.getDoors(); - if ((doors != null) && doors.contains(door)) + if (ch.getDoors().contains(door)) { return ch; } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java index 6aa0a1fdde..fb395b9e2d 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java @@ -17,10 +17,10 @@ package org.l2jmobius.gameserver.data.xml; import java.io.File; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -42,7 +42,7 @@ public class FakePlayerData implements IXmlReader private final Map _fakePlayerInfos = new HashMap<>(); private final Map _fakePlayerNames = new HashMap<>(); private final Map _fakePlayerIds = new HashMap<>(); - private final List _talkableFakePlayerNames = new ArrayList<>(); + private final Set _talkableFakePlayerNames = new HashSet<>(); protected FakePlayerData() { diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java index d335b95954..1122d7b9ba 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java @@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -49,7 +51,7 @@ import org.l2jmobius.gameserver.util.Util; public class SellBuffsManager implements IXmlReader { private static final Logger LOGGER = Logger.getLogger(SellBuffsManager.class.getName()); - private static final List ALLOWED_BUFFS = new ArrayList<>(); + private static final Set ALLOWED_BUFFS = new HashSet<>(); private static final String HTML_FOLDER = "data/html/mods/SellBuffs/"; protected SellBuffsManager() @@ -76,11 +78,7 @@ public class SellBuffsManager implements IXmlReader { final Element elem = (Element) node.item(i); final int skillId = Integer.parseInt(elem.getAttribute("id")); - - if (!ALLOWED_BUFFS.contains(skillId)) - { - ALLOWED_BUFFS.add(skillId); - } + ALLOWED_BUFFS.add(skillId); } } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java index b10f75ef3d..1e45a21319 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java @@ -19,8 +19,10 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; @@ -67,7 +69,7 @@ public class WalkingManager implements IXmlReader public static final byte REPEAT_TELE_FIRST = 2; public static final byte REPEAT_RANDOM = 3; - private final List _targetedNpcIds = new ArrayList<>(); + private final Set _targetedNpcIds = new HashSet<>(); private final Map _routes = new HashMap<>(); // all available routes private final Map _activeRoutes = new HashMap<>(); // each record represents NPC, moving by predefined route from _routes, and moving progress private final Map _routesToAttach = new HashMap<>(); // each record represents NPC and all available routes for it diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/BlockList.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/BlockList.java index 1af9941ed5..9ac6266e22 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/BlockList.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/BlockList.java @@ -19,9 +19,9 @@ package org.l2jmobius.gameserver.model; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -36,10 +36,11 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; public class BlockList { private static final Logger LOGGER = Logger.getLogger(BlockList.class.getName()); - private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); + + private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); private final Player _owner; - private List _blockList; + private Set _blockList; public BlockList(Player owner) { @@ -68,9 +69,9 @@ public class BlockList OFFLINE_LIST.put(_owner.getObjectId(), _blockList); } - private static List loadList(int objId) + private static Set loadList(int objId) { - final List list = new ArrayList<>(); + final Set list = new HashSet<>(); try (Connection con = DatabaseFactory.getConnection(); PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1")) { @@ -158,7 +159,7 @@ public class BlockList _owner.setMessageRefusal(value); } - private List getBlockList() + private Set getBlockList() { return _blockList; } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/PetData.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/PetData.java index b534c21f36..231b85e85f 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/PetData.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/PetData.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; import org.l2jmobius.gameserver.model.holders.SkillHolder; @@ -40,7 +42,7 @@ public class PetData private int _minLevel = Byte.MAX_VALUE; private int _maxLevel = 0; private boolean _syncLevel = false; - private final List _food = new ArrayList<>(); + private final Set _food = new HashSet<>(); public PetData(int npcId, int itemId) { @@ -133,7 +135,7 @@ public class PetData /** * @return the pet's food list. */ - public List getFood() + public Set getFood() { return _food; } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/SkillLearn.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/SkillLearn.java index a69d30f105..3d5704b5f2 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/SkillLearn.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/SkillLearn.java @@ -16,9 +16,8 @@ */ package org.l2jmobius.gameserver.model; -import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashSet; -import java.util.List; import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -40,12 +39,12 @@ public class SkillLearn private final int _getDualClassLevel; private final boolean _autoGet; private final long _levelUpSp; - private final List _requiredItems = new ArrayList<>(); - private final List _races = new ArrayList<>(); - private final List _preReqSkills = new ArrayList<>(); + private final Set _requiredItems = new HashSet<>(1); + private final Set _races = EnumSet.noneOf(Race.class); + private final Set _preReqSkills = new HashSet<>(1); private SocialClass _socialClass; private final boolean _residenceSkill; - private final List _residenceIds = new ArrayList<>(); + private final Set _residenceIds = new HashSet<>(1); private final boolean _learnedByNpc; private final boolean _learnedByFS; private final Set _removeSkills = new HashSet<>(1); @@ -133,9 +132,9 @@ public class SkillLearn } /** - * @return the list with the item holders required to acquire this skill. + * @return the set with the item holders required to acquire this skill. */ - public List getRequiredItems() + public Set getRequiredItems() { return _requiredItems; } @@ -150,9 +149,9 @@ public class SkillLearn } /** - * @return a list with the races that can acquire this skill. + * @return a set with the races that can acquire this skill. */ - public List getRaces() + public Set getRaces() { return _races; } @@ -167,9 +166,9 @@ public class SkillLearn } /** - * @return the list of skill holders required to acquire this skill. + * @return the set of skill holders required to acquire this skill. */ - public List getPreReqSkills() + public Set getPreReqSkills() { return _preReqSkills; } @@ -212,9 +211,9 @@ public class SkillLearn } /** - * @return a list with the Ids where this skill is available. + * @return a set with the Ids where this skill is available. */ - public List getResidenceIds() + public Set getResidenceIds() { return _residenceIds; } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java index d80071ca22..b088c8b8c9 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java @@ -22,7 +22,6 @@ import java.sql.ResultSet; import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.List; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; @@ -153,7 +152,7 @@ public class Pet extends Summon broadcastStatusUpdate(); - final List foodIds = getPetData().getFood(); + final Set foodIds = getPetData().getFood(); if (foodIds.isEmpty()) { if (isUncontrollable()) diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java index 11efe435d8..1ed0ee81a4 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java @@ -16,8 +16,8 @@ */ package org.l2jmobius.gameserver.model.actor.instance; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import org.l2jmobius.commons.threads.ThreadPool; @@ -57,7 +57,7 @@ public class Trap extends Npc private boolean _isTriggered; private final int _lifeTime; private Player _owner; - private final List _playersWhoDetectedMe = new ArrayList<>(); + private final Set _playersWhoDetectedMe = new HashSet<>(); private final SkillHolder _skill; private int _remainingTime; // Tasks diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java index 71ef076212..3ba8c20a9b 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor.tasks.player; -import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -69,11 +69,12 @@ public class PetFeedTask implements Runnable _player.sendPacket(SystemMessageId.YOU_ARE_OUT_OF_FEED_MOUNT_STATUS_CANCELED); } - final List foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); + final Set foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); if (foodIds.isEmpty()) { return; } + Item food = null; for (int id : foodIds) { diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java index 50d2a821c3..2611b5f121 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.actor.Creature; @@ -29,9 +29,9 @@ import org.l2jmobius.gameserver.model.zone.ZoneType; */ public class ConditionPlayerInsideZoneId extends Condition { - private final List _zones; + private final Set _zones; - public ConditionPlayerInsideZoneId(List zones) + public ConditionPlayerInsideZoneId(Set zones) { _zones = zones; } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java index c15065eca2..d644f663f5 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Player; @@ -29,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerInstanceId extends Condition { - private final List _instanceIds; + private final Set _instanceIds; /** * Instantiates a new condition player instance id. * @param instanceIds the instance ids */ - public ConditionPlayerInstanceId(List instanceIds) + public ConditionPlayerInstanceId(Set instanceIds) { _instanceIds = instanceIds; } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java index 14d61089ed..7c375ec45e 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -28,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerRace extends Condition { - private final Race[] _races; + private final Set _races; /** * Instantiates a new condition player race. * @param races the list containing the allowed races. */ - public ConditionPlayerRace(Race[] races) + public ConditionPlayerRace(Set races) { _races = races; } @@ -46,6 +47,6 @@ public class ConditionPlayerRace extends Condition { return false; } - return CommonUtil.contains(_races, effector.getActingPlayer().getRace()); + return _races.contains(effector.getActingPlayer().getRace()); } } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java index 0f54766571..0b326e3f40 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId())) + if (_npcIds.contains(target.getId())) { existNpc = true; break; diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java index c5c9b5ff0e..db64b6bd7b 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromSummonedNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromSummonedNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromSummonedNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromSummonedNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId()) && (effector == target.getSummoner())) + if (_npcIds.contains(target.getId()) && (effector == target.getSummoner())) { existNpc = true; break; diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java index a3fb0f5374..a47b4b4983 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetClassIdRestriction extends Condition { - private final List _classIds; + private final Set _classIds; /** * Instantiates a new condition target class id restriction. * @param classId the class id */ - public ConditionTargetClassIdRestriction(List classId) + public ConditionTargetClassIdRestriction(Set classId) { _classIds = classId; } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java index 82b1bd5877..9bb694f4ef 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetNpcId extends Condition { - private final List _npcIds; + private final Set _npcIds; /** * Instantiates a new condition target npc id. * @param npcIds the npc ids */ - public ConditionTargetNpcId(List npcIds) + public ConditionTargetNpcId(Set npcIds) { _npcIds = npcIds; } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java index f26329bc21..5c86f26ae5 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.holders; -import java.util.Collection; +import java.util.Set; /** * @author Mobius @@ -25,9 +25,9 @@ public class EventDropHolder extends DropHolder { private final int _minLevel; private final int _maxLevel; - private final Collection _monsterIds; + private final Set _monsterIds; - public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Collection monsterIds) + public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Set monsterIds) { super(null, itemId, min, max, chance); _minLevel = minLevel; @@ -45,7 +45,7 @@ public class EventDropHolder extends DropHolder return _maxLevel; } - public Collection getMonsterIds() + public Set getMonsterIds() { return _monsterIds; } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/item/Henna.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/item/Henna.java index 107656dba9..3fa8d06bc6 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/item/Henna.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/item/Henna.java @@ -17,9 +17,11 @@ package org.l2jmobius.gameserver.model.item; import java.util.ArrayList; -import java.util.HashMap; +import java.util.EnumMap; +import java.util.EnumSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.enums.ClassId; import org.l2jmobius.gameserver.model.StatSet; @@ -34,14 +36,14 @@ public class Henna { private final int _dyeId; private final int _dyeItemId; - private final Map _baseStats = new HashMap<>(); + private final Map _baseStats = new EnumMap<>(BaseStat.class); private final int _wearFee; private final int _wearCount; private final int _cancelFee; private final int _cancelCount; private final int _duration; private final List _skills; - private final List _wearClass; + private final Set _wearClass; public Henna(StatSet set) { @@ -59,7 +61,7 @@ public class Henna _cancelCount = set.getInt("cancel_count"); _duration = set.getInt("duration", -1); _skills = new ArrayList<>(); - _wearClass = new ArrayList<>(); + _wearClass = EnumSet.noneOf(ClassId.class); } /** @@ -147,7 +149,7 @@ public class Henna /** * @return the list with the allowed classes to wear this dye. */ - public List getAllowedWearClass() + public Set getAllowedWearClass() { return _wearClass; } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java index 18d7b61ca2..65402c4c89 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java @@ -17,9 +17,10 @@ package org.l2jmobius.gameserver.model.item.appearance; import java.time.Duration; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.enums.Race; @@ -47,12 +48,12 @@ public class AppearanceStone private final ArmorType _armorType; private final AppearanceHandType _handType; private final AppearanceMagicType _magicType; - private List _crystalTypes; - private List _targetTypes; - private List _bodyParts; - private List _races; - private List _racesNot; - private List _allVisualIds; + private Set _crystalTypes; + private Set _targetTypes; + private Set _bodyParts; + private Set _races; + private Set _racesNot; + private Set _allVisualIds; public AppearanceStone(StatSet set) { @@ -172,35 +173,35 @@ public class AppearanceStone { if (_crystalTypes == null) { - _crystalTypes = new ArrayList<>(); + _crystalTypes = EnumSet.noneOf(CrystalType.class); } _crystalTypes.add(type); } - public List getCrystalTypes() + public Set getCrystalTypes() { - return _crystalTypes != null ? _crystalTypes : Collections.emptyList(); + return _crystalTypes != null ? _crystalTypes : Collections.emptySet(); } public void addTargetType(AppearanceTargetType type) { if (_targetTypes == null) { - _targetTypes = new ArrayList<>(); + _targetTypes = EnumSet.noneOf(AppearanceTargetType.class); } _targetTypes.add(type); } - public List getTargetTypes() + public Set getTargetTypes() { - return _targetTypes != null ? _targetTypes : Collections.emptyList(); + return _targetTypes != null ? _targetTypes : Collections.emptySet(); } public void addBodyPart(Integer part) { if (_bodyParts == null) { - _bodyParts = new ArrayList<>(); + _bodyParts = new HashSet<>(); } _bodyParts.add(part); } @@ -209,47 +210,47 @@ public class AppearanceStone { if (_allVisualIds == null) { - _allVisualIds = new ArrayList<>(); + _allVisualIds = new HashSet<>(); } _allVisualIds.add(appearanceHolder); } - public List getVisualIds() + public Set getVisualIds() { - return _allVisualIds != null ? _allVisualIds : Collections.emptyList(); + return _allVisualIds != null ? _allVisualIds : Collections.emptySet(); } - public List getBodyParts() + public Set getBodyParts() { - return _bodyParts != null ? _bodyParts : Collections.emptyList(); + return _bodyParts != null ? _bodyParts : Collections.emptySet(); } public void addRace(Race race) { if (_races == null) { - _races = new ArrayList<>(); + _races = EnumSet.noneOf(Race.class); } _races.add(race); } - public List getRaces() + public Set getRaces() { - return _races != null ? _races : Collections.emptyList(); + return _races != null ? _races : Collections.emptySet(); } public void addRaceNot(Race race) { if (_racesNot == null) { - _racesNot = new ArrayList<>(); + _racesNot = EnumSet.noneOf(Race.class); } _racesNot.add(race); } - public List getRacesNot() + public Set getRacesNot() { - return _racesNot != null ? _racesNot : Collections.emptyList(); + return _racesNot != null ? _racesNot : Collections.emptySet(); } /** @@ -302,7 +303,7 @@ public class AppearanceStone { // Seems like in retail item with already changed appearance, can be changed again without being restored. - final AppearanceTargetType targetType = getTargetTypes().get(0); + final AppearanceTargetType targetType = getTargetTypes().stream().findFirst().get(); switch (targetType) { case NONE: diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java index 5d3a79d524..5e067a67e5 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java @@ -16,16 +16,16 @@ */ package org.l2jmobius.gameserver.model.item.enchant; +import java.util.EnumSet; +import java.util.Set; import java.util.logging.Logger; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.item.ItemTemplate; import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.model.item.type.CrystalType; import org.l2jmobius.gameserver.model.item.type.EtcItemType; -import org.l2jmobius.gameserver.model.item.type.ItemType; /** * @author UnAfraid @@ -34,26 +34,27 @@ public abstract class AbstractEnchantItem { protected static final Logger LOGGER = Logger.getLogger(AbstractEnchantItem.class.getName()); - private static final ItemType[] ENCHANT_TYPES = new ItemType[] + private static final Set ENCHANT_TYPES = EnumSet.noneOf(EtcItemType.class); + static { - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM, - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP, - EtcItemType.BLESS_ENCHT_AM, - EtcItemType.BLESS_ENCHT_AM_DOWN, - EtcItemType.BLESS_ENCHT_WP, - EtcItemType.ENCHT_AM, - EtcItemType.ENCHT_WP, - EtcItemType.GIANT_ENCHT_AM, - EtcItemType.GIANT_ENCHT_WP, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - }; + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + } private final int _id; private final CrystalType _grade; @@ -71,7 +72,7 @@ public abstract class AbstractEnchantItem { throw new NullPointerException(); } - else if (!CommonUtil.contains(ENCHANT_TYPES, getItem().getItemType())) + else if (!ENCHANT_TYPES.contains(getItem().getItemType())) { throw new IllegalAccessError(); } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java index 5ba6755084..18508d0145 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java @@ -24,8 +24,10 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Set; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -184,7 +186,7 @@ public class LongTimeEvent extends Quest final Node maxLevelNode = d.getAttributes().getNamedItem("maxLevel"); final int maxLevel = maxLevelNode == null ? Integer.MAX_VALUE : Integer.parseInt(maxLevelNode.getNodeValue()); final Node monsterIdsNode = d.getAttributes().getNamedItem("monsterIds"); - final List monsterIds = new ArrayList<>(); + final Set monsterIds = new HashSet<>(); if (monsterIdsNode != null) { for (String id : monsterIdsNode.getNodeValue().split(",")) diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/residences/ClanHall.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/residences/ClanHall.java index 0c0a529077..fcc850371b 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/residences/ClanHall.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/residences/ClanHall.java @@ -23,7 +23,9 @@ import java.sql.SQLException; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -61,9 +63,9 @@ public class ClanHall extends AbstractResidence private final int _minBid; final int _lease; private final int _deposit; - private final List _npcs; - private final List _doors; - private final List _teleports; + private final Set _npcs = new HashSet<>(); + private final Set _doors = new HashSet<>(); + private final Set _teleports = new HashSet<>(); private final Location _ownerLocation; private final Location _banishLocation; // Dynamic parameters @@ -85,9 +87,21 @@ public class ClanHall extends AbstractResidence _minBid = params.getInt("minBid"); _lease = params.getInt("lease"); _deposit = params.getInt("deposit"); - _npcs = params.getList("npcList", Integer.class); - _doors = params.getList("doorList", Door.class); - _teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + final List npcs = params.getList("npcList", Integer.class); + if (npcs != null) + { + _npcs.addAll(npcs); + } + final List doors = params.getList("doorList", Door.class); + if (doors != null) + { + _doors.addAll(doors); + } + final List teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + if (teleports != null) + { + _teleports.addAll(teleports); + } _ownerLocation = params.getLocation("owner_loc"); _banishLocation = params.getLocation("banish_loc"); // Set dynamic parameters (from DB) @@ -196,7 +210,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Door} related to this {@link ClanHall}. * @return all {@link Door} related to this {@link ClanHall} */ - public List getDoors() + public Set getDoors() { return _doors; } @@ -205,7 +219,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Npc} related to this {@link ClanHall}. * @return all {@link Npc} related to this {@link ClanHall} */ - public List getNpcs() + public Set getNpcs() { return _npcs; } @@ -324,7 +338,7 @@ public class ClanHall extends AbstractResidence return _banishLocation; } - public List getTeleportList() + public Set getTeleportList() { return _teleports; } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/siege/Castle.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/siege/Castle.java index d053196bec..4e90413baf 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/siege/Castle.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/siege/Castle.java @@ -21,8 +21,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.Calendar; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -83,7 +85,7 @@ public class Castle extends AbstractResidence private SiegeZone _zone = null; private ResidenceTeleportZone _teleZone; private Clan _formerOwner = null; - private final List _artefacts = new ArrayList<>(1); + private final Set _artefacts = new HashSet<>(1); private final Map _function = new ConcurrentHashMap<>(); private int _ticketBuyCount = 0; private boolean _isFirstMidVictory = false; @@ -1072,7 +1074,7 @@ public class Castle extends AbstractResidence _artefacts.add(artefact); } - public List getArtefacts() + public Set getArtefacts() { return _artefacts; } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java index 0c79677eae..4ebf954ee5 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.network.serverpackets; -import java.util.List; +import java.util.Set; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.gameserver.data.sql.CharNameTable; @@ -27,19 +27,19 @@ import org.l2jmobius.gameserver.network.OutgoingPackets; */ public class BlockListPacket implements IClientOutgoingPacket { - private final List _playersId; + private final Set _playerIds; - public BlockListPacket(List playersId) + public BlockListPacket(Set playerIds) { - _playersId = playersId; + _playerIds = playerIds; } @Override public boolean write(PacketWriter packet) { OutgoingPackets.BLOCK_LIST.writeId(packet); - packet.writeD(_playersId.size()); - for (int playerId : _playersId) + packet.writeD(_playerIds.size()); + for (int playerId : _playerIds) { packet.writeS(CharNameTable.getInstance().getNameById(playerId)); packet.writeS(""); // memo ? diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java index 8555bb6e86..eb5bfd05d8 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.network.serverpackets; import java.util.List; import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; import org.l2jmobius.commons.network.PacketWriter; @@ -37,7 +38,7 @@ public class ExAcquireSkillInfo implements IClientOutgoingPacket private final int _dualClassLevel; private final long _spCost; private final int _minLevel; - private final List _itemReq; + private final Set _itemReq; private final List _skillRem; /** diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java index 84b5fead76..a163a85735 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java @@ -35,7 +35,7 @@ public class ExChooseShapeShiftingItem implements IClientOutgoingPacket public ExChooseShapeShiftingItem(AppearanceStone stone) { _type = stone.getType(); - _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().get(0); + _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().stream().findFirst().get(); _itemId = stone.getId(); } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/DocumentBase.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/DocumentBase.java index 8a8e13d940..c22140b9c4 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/DocumentBase.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/DocumentBase.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.util; import java.io.File; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -390,12 +391,12 @@ public abstract class DocumentBase case "races": { final String[] racesVal = a.getNodeValue().split(","); - final Race[] races = new Race[racesVal.length]; + final Set races = EnumSet.noneOf(Race.class); for (int r = 0; r < racesVal.length; r++) { if (racesVal[r] != null) { - races[r] = Race.valueOf(racesVal[r]); + races.add(Race.valueOf(racesVal[r])); } } cond = joinAnd(cond, new ConditionPlayerRace(races)); @@ -671,13 +672,13 @@ public abstract class DocumentBase case "instanceid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final ArrayList array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInstanceId(array)); + cond = joinAnd(cond, new ConditionPlayerInstanceId(set)); break; } case "agathionid": @@ -728,10 +729,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -745,10 +746,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -834,13 +835,13 @@ public abstract class DocumentBase case "insidezoneid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInsideZoneId(array)); + cond = joinAnd(cond, new ConditionPlayerInsideZoneId(set)); break; } case "checkabnormal": @@ -961,13 +962,13 @@ public abstract class DocumentBase case "class_id_restriction": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetClassIdRestriction(array)); + cond = joinAnd(cond, new ConditionTargetClassIdRestriction(set)); break; } case "active_effect_id": @@ -1045,13 +1046,13 @@ public abstract class DocumentBase case "npcid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetNpcId(array)); + cond = joinAnd(cond, new ConditionTargetNpcId(set)); break; } case "npctype": diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/bypasshandlers/Link.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/bypasshandlers/Link.java index 5097e77f56..2cb1581627 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/bypasshandlers/Link.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/bypasshandlers/Link.java @@ -16,7 +16,9 @@ */ package handlers.bypasshandlers; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.HashSet; +import java.util.Set; + import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.handler.IBypassHandler; import org.l2jmobius.gameserver.model.actor.Creature; @@ -31,28 +33,29 @@ public class Link implements IBypassHandler "Link" }; - private static final String[] VALID_LINKS = + private static final Set VALID_LINKS = new HashSet<>(); + static { - "common/craft_01.htm", - "common/craft_02.htm", - "common/runes_01.htm", - "common/skill_enchant_help_01.htm", - "common/skill_enchant_help_02.htm", - "common/skill_enchant_help_03.htm", - "default/BlessingOfProtection.htm", - "default/SupportMagic.htm", - "fisherman/fishing_manual001.htm", - "fisherman/fishing_manual002.htm", - "fisherman/fishing_manual003.htm", - "fisherman/fishing_manual004.htm", - "fisherman/fishing_manual005.htm", - "fortress/foreman.htm", - "petmanager/evolve.htm", - "petmanager/exchange.htm", - "petmanager/instructions.htm", - "warehouse/clanwh.htm", - "warehouse/privatewh.htm", - }; + VALID_LINKS.add("common/craft_01.htm"); + VALID_LINKS.add("common/craft_02.htm"); + VALID_LINKS.add("common/runes_01.htm"); + VALID_LINKS.add("common/skill_enchant_help_01.htm"); + VALID_LINKS.add("common/skill_enchant_help_02.htm"); + VALID_LINKS.add("common/skill_enchant_help_03.htm"); + VALID_LINKS.add("default/BlessingOfProtection.htm"); + VALID_LINKS.add("default/SupportMagic.htm"); + VALID_LINKS.add("fisherman/fishing_manual001.htm"); + VALID_LINKS.add("fisherman/fishing_manual002.htm"); + VALID_LINKS.add("fisherman/fishing_manual003.htm"); + VALID_LINKS.add("fisherman/fishing_manual004.htm"); + VALID_LINKS.add("fisherman/fishing_manual008.htm"); + VALID_LINKS.add("fortress/foreman.htm"); + VALID_LINKS.add("petmanager/evolve.htm"); + VALID_LINKS.add("petmanager/exchange.htm"); + VALID_LINKS.add("petmanager/instructions.htm"); + VALID_LINKS.add("warehouse/clanwh.htm"); + VALID_LINKS.add("warehouse/privatewh.htm"); + } @Override public boolean useBypass(String command, Player player, Creature target) @@ -70,12 +73,13 @@ public class Link implements IBypassHandler return false; } - String content = CommonUtil.contains(VALID_LINKS, htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; + String content = VALID_LINKS.contains(htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; // Precaution. if (htmlPath.startsWith("teleporter/") && !(player.getTarget() instanceof Teleporter)) { content = null; } + final NpcHtmlMessage html = new NpcHtmlMessage(target != null ? target.getObjectId() : 0); if (content != null) { diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java index b18ea0d506..171c3003dd 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java @@ -16,8 +16,9 @@ */ package handlers.dailymissionhandlers; -import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.Config; import org.l2jmobius.gameserver.enums.DailyMissionStatus; @@ -41,7 +42,7 @@ public class MonsterDailyMissionHandler extends AbstractDailyMissionHandler private final int _amount; private final int _minLevel; private final int _maxLevel; - private final List _ids = new ArrayList<>(); + private final Set _ids = new HashSet<>(); public MonsterDailyMissionHandler(DailyMissionDataHolder holder) { diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/itemhandlers/PetFood.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/itemhandlers/PetFood.java index 3c5572d4ec..8b908ea095 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/itemhandlers/PetFood.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/itemhandlers/PetFood.java @@ -17,6 +17,7 @@ package handlers.itemhandlers; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.PetDataTable; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -79,7 +80,7 @@ public class PetFood implements IItemHandler final Player player = activeChar.getActingPlayer(); if (player.isMounted()) { - final List foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); + final Set foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); if (foodIds.contains(item.getId()) && player.destroyItem("Consume", item.getObjectId(), 1, null, false)) { player.broadcastPacket(new MagicSkillUse(player, player, skillId, skillLevel, 0, 0)); diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java index 2ad282f683..99f45fbb41 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.ClanHallData; import org.l2jmobius.gameserver.model.StatSet; @@ -32,12 +33,12 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpCheckResidenceSkillCondition implements ISkillCondition { - private final List _residencesId; + private final Set _residencesId = new HashSet<>(); private final boolean _isWithin; public OpCheckResidenceSkillCondition(StatSet params) { - _residencesId = params.getList("residencesId", Integer.class); + _residencesId.addAll(params.getList("residencesId", Integer.class)); _isWithin = params.getBoolean("isWithin"); } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java index fc2934423b..4a8282d988 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java @@ -16,9 +16,9 @@ */ package handlers.skillconditionhandlers; -import java.util.ArrayList; -import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -28,18 +28,18 @@ import org.l2jmobius.gameserver.model.skill.ISkillCondition; import org.l2jmobius.gameserver.model.skill.Skill; /** - * @author UnAfraid + * @author UnAfraid, Mobius */ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition { - private final List _npcIds = new ArrayList<>(); + private final Set _npcIds = new HashSet<>(); public OpNeedSummonOrPetSkillCondition(StatSet params) { - final List npcIds = params.getList("npcIds", String.class); + final List npcIds = params.getList("npcIds", Integer.class); if (npcIds != null) { - npcIds.stream().map(Integer::valueOf).forEach(_npcIds::add); + _npcIds.addAll(npcIds); } } @@ -47,7 +47,19 @@ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition public boolean canUse(Creature caster, Skill skill, WorldObject target) { final Summon pet = caster.getPet(); - final Collection summons = caster.getServitors().values(); - return ((pet != null) && _npcIds.stream().anyMatch(npcId -> npcId == pet.getId())) || summons.stream().anyMatch(summon -> _npcIds.contains(summon.getId())); + if ((pet != null) && _npcIds.contains(pet.getId())) + { + return true; + } + + for (Summon summon : caster.getServitors().values()) + { + if (_npcIds.contains(summon.getId())) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java index 8541bc62b4..ef81b291d4 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,11 +30,11 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetDoorSkillCondition implements ISkillCondition { - private final List _doorIds; + private final Set _doorIds = new HashSet<>(); public OpTargetDoorSkillCondition(StatSet params) { - _doorIds = params.getList("doorIds", Integer.class); + _doorIds.addAll(params.getList("doorIds", Integer.class)); } @Override diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java index 3ce4145703..0ccd571e19 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,17 +30,17 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetNpcSkillCondition implements ISkillCondition { - private final List _npcId; + private final Set _npcIds = new HashSet<>(); public OpTargetNpcSkillCondition(StatSet params) { - _npcId = params.getList("npcIds", Integer.class); + _npcIds.addAll(params.getList("npcIds", Integer.class)); } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget(); - return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId()); + return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcIds.contains(actualTarget.getId()); } } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/instances/AbstractInstance.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/instances/AbstractInstance.java index d485c2c36d..4a0a3d35d4 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/instances/AbstractInstance.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/instances/AbstractInstance.java @@ -16,9 +16,10 @@ */ package instances; +import java.util.HashSet; import java.util.List; +import java.util.Set; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.enums.InstanceReenterType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.instancemanager.InstanceManager; @@ -40,25 +41,29 @@ import ai.AbstractNpcAI; */ public abstract class AbstractInstance extends AbstractNpcAI { - private final int[] _templateIds; + private final Set _templateIds = new HashSet<>(); - public AbstractInstance(int... templateId) + public AbstractInstance(int... templateIds) { - if (templateId.length == 0) + if (templateIds.length == 0) { throw new IllegalStateException("No template ids were provided!"); } - _templateIds = templateId; + + for (int templateId : templateIds) + { + _templateIds.add(templateId); + } } - public int[] getTemplateId() + public Set getTemplateId() { return _templateIds; } public boolean isInInstance(Instance instance) { - return (instance != null) && CommonUtil.contains(_templateIds, instance.getTemplateId()); + return (instance != null) && _templateIds.contains(instance.getTemplateId()); } /** diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/Config.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/Config.java index 008876b684..3e236fa602 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/Config.java @@ -288,7 +288,7 @@ public class Config public static boolean AUTO_LOOT_SLOT_LIMIT; public static int LOOT_RAIDS_PRIVILEGE_INTERVAL; public static int LOOT_RAIDS_PRIVILEGE_CC_SIZE; - public static List AUTO_LOOT_ITEM_IDS; + public static Set AUTO_LOOT_ITEM_IDS; public static boolean ENABLE_KEYBOARD_MOVEMENT; public static int UNSTUCK_INTERVAL; public static int TELEPORT_WATCHDOG_TIMEOUT; @@ -477,7 +477,7 @@ public class Config public static boolean ALLOW_DISCARDITEM; public static int AUTODESTROY_ITEM_AFTER; public static int HERB_AUTO_DESTROY_TIME; - public static List LIST_PROTECTED_ITEMS; + public static Set LIST_PROTECTED_ITEMS; public static boolean DATABASE_CLEAN_UP; public static int CHAR_DATA_STORE_INTERVAL; public static int CLAN_VARIABLES_STORE_INTERVAL; @@ -568,7 +568,7 @@ public class Config public static boolean ALT_OLY_LOG_FIGHTS; public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS; public static boolean ALT_OLY_ANNOUNCE_GAMES; - public static List LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(); + public static Set LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(); public static int ALT_OLY_WEAPON_ENCHANT_LIMIT; public static int ALT_OLY_ARMOR_ENCHANT_LIMIT; public static int ALT_OLY_WAIT_TIME; @@ -1195,9 +1195,9 @@ public class Config public static int AUTO_CP_PERCENTAGE; public static int AUTO_HP_PERCENTAGE; public static int AUTO_MP_PERCENTAGE; - public static List AUTO_CP_ITEM_IDS; - public static List AUTO_HP_ITEM_IDS; - public static List AUTO_MP_ITEM_IDS; + public static Set AUTO_CP_ITEM_IDS; + public static Set AUTO_HP_ITEM_IDS; + public static Set AUTO_MP_ITEM_IDS; public static boolean CUSTOM_STARTING_LOC; public static int CUSTOM_STARTING_LOC_X; public static int CUSTOM_STARTING_LOC_Y; @@ -1207,7 +1207,7 @@ public class Config public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; public static int MOB_MIN_SPAWN_RANGE; public static int MOB_MAX_SPAWN_RANGE; - public static List MOBS_LIST_NOT_RANDOM; + public static Set MOBS_LIST_NOT_RANDOM; public static boolean FREE_JUMPS_FOR_ALL; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; @@ -1226,7 +1226,7 @@ public class Config public static boolean COMMUNITY_PREMIUM_SYSTEM_ENABLED; public static int COMMUNITY_PREMIUM_COIN_ID; public static int COMMUNITY_PREMIUM_PRICE_PER_DAY; - public static List COMMUNITY_AVAILABLE_BUFFS; + public static Set COMMUNITY_AVAILABLE_BUFFS; public static Map COMMUNITY_AVAILABLE_TELEPORTS; public static boolean CUSTOM_DEPOSITABLE_ENABLED; public static boolean CUSTOM_DEPOSITABLE_QUEST_ITEMS; @@ -1874,7 +1874,7 @@ public class Config LOOT_RAIDS_PRIVILEGE_INTERVAL = characterConfig.getInt("RaidLootRightsInterval", 900) * 1000; LOOT_RAIDS_PRIVILEGE_CC_SIZE = characterConfig.getInt("RaidLootRightsCCSize", 45); final String[] autoLootItemIds = characterConfig.getString("AutoLootItemIds", "0").split(","); - AUTO_LOOT_ITEM_IDS = new ArrayList<>(autoLootItemIds.length); + AUTO_LOOT_ITEM_IDS = new HashSet<>(autoLootItemIds.length); for (String item : autoLootItemIds) { Integer itm = 0; @@ -2043,7 +2043,7 @@ public class Config AUTODESTROY_ITEM_AFTER = generalConfig.getInt("AutoDestroyDroppedItemAfter", 600); HERB_AUTO_DESTROY_TIME = generalConfig.getInt("AutoDestroyHerbTime", 60) * 1000; final String[] split = generalConfig.getString("ListOfProtectedItems", "0").split(","); - LIST_PROTECTED_ITEMS = new ArrayList<>(split.length); + LIST_PROTECTED_ITEMS = new HashSet<>(split.length); for (String id : split) { LIST_PROTECTED_ITEMS.add(Integer.parseInt(id)); @@ -2456,7 +2456,7 @@ public class Config if (!olyRestrictedItems.isEmpty()) { final String[] olyRestrictedItemsSplit = olyRestrictedItems.split(","); - LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(olyRestrictedItemsSplit.length); + LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(olyRestrictedItemsSplit.length); for (String id : olyRestrictedItemsSplit) { LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id)); @@ -2570,17 +2570,17 @@ public class Config AUTO_CP_PERCENTAGE = autoPotionsConfig.getInt("AutoCpPercentage", 70); AUTO_HP_PERCENTAGE = autoPotionsConfig.getInt("AutoHpPercentage", 70); AUTO_MP_PERCENTAGE = autoPotionsConfig.getInt("AutoMpPercentage", 70); - AUTO_CP_ITEM_IDS = new ArrayList<>(); + AUTO_CP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoCpItemIds", "0").split(",")) { AUTO_CP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_HP_ITEM_IDS = new ArrayList<>(); + AUTO_HP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoHpItemIds", "0").split(",")) { AUTO_HP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_MP_ITEM_IDS = new ArrayList<>(); + AUTO_MP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoMpItemIds", "0").split(",")) { AUTO_MP_ITEM_IDS.add(Integer.parseInt(s)); @@ -3190,7 +3190,7 @@ public class Config COMMUNITY_PREMIUM_COIN_ID = communityBoardConfig.getInt("CommunityPremiumBuyCoinId", 57); COMMUNITY_PREMIUM_PRICE_PER_DAY = communityBoardConfig.getInt("CommunityPremiumPricePerDay", 1000000); final String[] allowedBuffs = communityBoardConfig.getString("CommunityAvailableBuffs", "").split(","); - COMMUNITY_AVAILABLE_BUFFS = new ArrayList<>(allowedBuffs.length); + COMMUNITY_AVAILABLE_BUFFS = new HashSet<>(allowedBuffs.length); for (String s : allowedBuffs) { COMMUNITY_AVAILABLE_BUFFS.add(Integer.parseInt(s)); @@ -3474,7 +3474,7 @@ public class Config if (ENABLE_RANDOM_MONSTER_SPAWNS) { final String[] mobsIds = randomSpawnsConfig.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); - MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + MOBS_LIST_NOT_RANDOM = new HashSet<>(mobsIds.length); for (String id : mobsIds) { MOBS_LIST_NOT_RANDOM.add(Integer.parseInt(id)); diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java index d6e0183c6f..c3977185b4 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java @@ -202,8 +202,7 @@ public class ClanHallData implements IXmlReader final Door door = DoorData.getInstance().getDoor(doorId); for (ClanHall ch : _clanHalls.values()) { - final List doors = ch.getDoors(); - if ((doors != null) && doors.contains(door)) + if (ch.getDoors().contains(door)) { return ch; } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java index 6aa0a1fdde..fb395b9e2d 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java @@ -17,10 +17,10 @@ package org.l2jmobius.gameserver.data.xml; import java.io.File; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -42,7 +42,7 @@ public class FakePlayerData implements IXmlReader private final Map _fakePlayerInfos = new HashMap<>(); private final Map _fakePlayerNames = new HashMap<>(); private final Map _fakePlayerIds = new HashMap<>(); - private final List _talkableFakePlayerNames = new ArrayList<>(); + private final Set _talkableFakePlayerNames = new HashSet<>(); protected FakePlayerData() { diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/VariationData.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/VariationData.java index c29a10baa2..079f5b3077 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/VariationData.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/VariationData.java @@ -20,8 +20,10 @@ import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Logger; @@ -114,14 +116,11 @@ public class VariationData implements IXmlReader }); // Support for specific item ids. - final List itemIds = new ArrayList<>(); + final Set itemIds = new HashSet<>(); forEach(categoryNode, "item", optionNode -> { final int itemId = parseInteger(optionNode.getAttributes(), "id"); - if (!itemIds.contains(itemId)) - { - itemIds.add(itemId); - } + itemIds.add(itemId); }); forEach(categoryNode, "items", optionNode -> { @@ -129,10 +128,7 @@ public class VariationData implements IXmlReader final int toId = parseInteger(optionNode.getAttributes(), "to"); for (int id = fromId; id <= toId; id++) { - if (!itemIds.contains(id)) - { - itemIds.add(id); - } + itemIds.add(id); } }); diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java index d335b95954..1122d7b9ba 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java @@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -49,7 +51,7 @@ import org.l2jmobius.gameserver.util.Util; public class SellBuffsManager implements IXmlReader { private static final Logger LOGGER = Logger.getLogger(SellBuffsManager.class.getName()); - private static final List ALLOWED_BUFFS = new ArrayList<>(); + private static final Set ALLOWED_BUFFS = new HashSet<>(); private static final String HTML_FOLDER = "data/html/mods/SellBuffs/"; protected SellBuffsManager() @@ -76,11 +78,7 @@ public class SellBuffsManager implements IXmlReader { final Element elem = (Element) node.item(i); final int skillId = Integer.parseInt(elem.getAttribute("id")); - - if (!ALLOWED_BUFFS.contains(skillId)) - { - ALLOWED_BUFFS.add(skillId); - } + ALLOWED_BUFFS.add(skillId); } } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java index b10f75ef3d..1e45a21319 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java @@ -19,8 +19,10 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; @@ -67,7 +69,7 @@ public class WalkingManager implements IXmlReader public static final byte REPEAT_TELE_FIRST = 2; public static final byte REPEAT_RANDOM = 3; - private final List _targetedNpcIds = new ArrayList<>(); + private final Set _targetedNpcIds = new HashSet<>(); private final Map _routes = new HashMap<>(); // all available routes private final Map _activeRoutes = new HashMap<>(); // each record represents NPC, moving by predefined route from _routes, and moving progress private final Map _routesToAttach = new HashMap<>(); // each record represents NPC and all available routes for it diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/BlockList.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/BlockList.java index d9ef2e01fb..984f05b22d 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/BlockList.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/BlockList.java @@ -19,9 +19,9 @@ package org.l2jmobius.gameserver.model; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -36,10 +36,11 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; public class BlockList { private static final Logger LOGGER = Logger.getLogger(BlockList.class.getName()); - private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); + + private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); private final Player _owner; - private List _blockList; + private Set _blockList; public BlockList(Player owner) { @@ -68,9 +69,9 @@ public class BlockList OFFLINE_LIST.put(_owner.getObjectId(), _blockList); } - private static List loadList(int objId) + private static Set loadList(int objId) { - final List list = new ArrayList<>(); + final Set list = new HashSet<>(); try (Connection con = DatabaseFactory.getConnection(); PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1")) { @@ -158,7 +159,7 @@ public class BlockList _owner.setMessageRefusal(value); } - private List getBlockList() + private Set getBlockList() { return _blockList; } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/PetData.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/PetData.java index c7c1b277b5..de645c8cd6 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/PetData.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/PetData.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; import org.l2jmobius.gameserver.enums.EvolveLevel; @@ -41,7 +43,7 @@ public class PetData private int _minLevel = Byte.MAX_VALUE; private int _maxLevel = 0; private boolean _syncLevel = false; - private final List _food = new ArrayList<>(); + private final Set _food = new HashSet<>(); private final int _petType; private final int _index; private final int _type; @@ -158,7 +160,7 @@ public class PetData /** * @return the pet's food list. */ - public List getFood() + public Set getFood() { return _food; } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/SkillLearn.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/SkillLearn.java index a69d30f105..3d5704b5f2 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/SkillLearn.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/SkillLearn.java @@ -16,9 +16,8 @@ */ package org.l2jmobius.gameserver.model; -import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashSet; -import java.util.List; import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -40,12 +39,12 @@ public class SkillLearn private final int _getDualClassLevel; private final boolean _autoGet; private final long _levelUpSp; - private final List _requiredItems = new ArrayList<>(); - private final List _races = new ArrayList<>(); - private final List _preReqSkills = new ArrayList<>(); + private final Set _requiredItems = new HashSet<>(1); + private final Set _races = EnumSet.noneOf(Race.class); + private final Set _preReqSkills = new HashSet<>(1); private SocialClass _socialClass; private final boolean _residenceSkill; - private final List _residenceIds = new ArrayList<>(); + private final Set _residenceIds = new HashSet<>(1); private final boolean _learnedByNpc; private final boolean _learnedByFS; private final Set _removeSkills = new HashSet<>(1); @@ -133,9 +132,9 @@ public class SkillLearn } /** - * @return the list with the item holders required to acquire this skill. + * @return the set with the item holders required to acquire this skill. */ - public List getRequiredItems() + public Set getRequiredItems() { return _requiredItems; } @@ -150,9 +149,9 @@ public class SkillLearn } /** - * @return a list with the races that can acquire this skill. + * @return a set with the races that can acquire this skill. */ - public List getRaces() + public Set getRaces() { return _races; } @@ -167,9 +166,9 @@ public class SkillLearn } /** - * @return the list of skill holders required to acquire this skill. + * @return the set of skill holders required to acquire this skill. */ - public List getPreReqSkills() + public Set getPreReqSkills() { return _preReqSkills; } @@ -212,9 +211,9 @@ public class SkillLearn } /** - * @return a list with the Ids where this skill is available. + * @return a set with the Ids where this skill is available. */ - public List getResidenceIds() + public Set getResidenceIds() { return _residenceIds; } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java index 72f271fb33..6801a921df 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java @@ -263,7 +263,7 @@ public class Pet extends Summon broadcastStatusUpdate(); - final List foodIds = getPetData().getFood(); + final Set foodIds = getPetData().getFood(); if (foodIds.isEmpty()) { if (isUncontrollable()) diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java index ddd5c20f5c..650e0257d2 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java @@ -16,8 +16,8 @@ */ package org.l2jmobius.gameserver.model.actor.instance; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import org.l2jmobius.commons.threads.ThreadPool; @@ -57,7 +57,7 @@ public class Trap extends Npc private boolean _isTriggered; private final int _lifeTime; private Player _owner; - private final List _playersWhoDetectedMe = new ArrayList<>(); + private final Set _playersWhoDetectedMe = new HashSet<>(); private final SkillHolder _skill; private int _remainingTime; // Tasks diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java index 71ef076212..3ba8c20a9b 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor.tasks.player; -import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -69,11 +69,12 @@ public class PetFeedTask implements Runnable _player.sendPacket(SystemMessageId.YOU_ARE_OUT_OF_FEED_MOUNT_STATUS_CANCELED); } - final List foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); + final Set foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); if (foodIds.isEmpty()) { return; } + Item food = null; for (int id : foodIds) { diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java index 50d2a821c3..2611b5f121 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.actor.Creature; @@ -29,9 +29,9 @@ import org.l2jmobius.gameserver.model.zone.ZoneType; */ public class ConditionPlayerInsideZoneId extends Condition { - private final List _zones; + private final Set _zones; - public ConditionPlayerInsideZoneId(List zones) + public ConditionPlayerInsideZoneId(Set zones) { _zones = zones; } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java index c15065eca2..d644f663f5 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Player; @@ -29,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerInstanceId extends Condition { - private final List _instanceIds; + private final Set _instanceIds; /** * Instantiates a new condition player instance id. * @param instanceIds the instance ids */ - public ConditionPlayerInstanceId(List instanceIds) + public ConditionPlayerInstanceId(Set instanceIds) { _instanceIds = instanceIds; } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java index 14d61089ed..7c375ec45e 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -28,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerRace extends Condition { - private final Race[] _races; + private final Set _races; /** * Instantiates a new condition player race. * @param races the list containing the allowed races. */ - public ConditionPlayerRace(Race[] races) + public ConditionPlayerRace(Set races) { _races = races; } @@ -46,6 +47,6 @@ public class ConditionPlayerRace extends Condition { return false; } - return CommonUtil.contains(_races, effector.getActingPlayer().getRace()); + return _races.contains(effector.getActingPlayer().getRace()); } } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java index 0f54766571..0b326e3f40 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId())) + if (_npcIds.contains(target.getId())) { existNpc = true; break; diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java index c5c9b5ff0e..db64b6bd7b 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromSummonedNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromSummonedNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromSummonedNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromSummonedNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId()) && (effector == target.getSummoner())) + if (_npcIds.contains(target.getId()) && (effector == target.getSummoner())) { existNpc = true; break; diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java index a3fb0f5374..a47b4b4983 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetClassIdRestriction extends Condition { - private final List _classIds; + private final Set _classIds; /** * Instantiates a new condition target class id restriction. * @param classId the class id */ - public ConditionTargetClassIdRestriction(List classId) + public ConditionTargetClassIdRestriction(Set classId) { _classIds = classId; } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java index 82b1bd5877..9bb694f4ef 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetNpcId extends Condition { - private final List _npcIds; + private final Set _npcIds; /** * Instantiates a new condition target npc id. * @param npcIds the npc ids */ - public ConditionTargetNpcId(List npcIds) + public ConditionTargetNpcId(Set npcIds) { _npcIds = npcIds; } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java index f26329bc21..5c86f26ae5 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.holders; -import java.util.Collection; +import java.util.Set; /** * @author Mobius @@ -25,9 +25,9 @@ public class EventDropHolder extends DropHolder { private final int _minLevel; private final int _maxLevel; - private final Collection _monsterIds; + private final Set _monsterIds; - public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Collection monsterIds) + public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Set monsterIds) { super(null, itemId, min, max, chance); _minLevel = minLevel; @@ -45,7 +45,7 @@ public class EventDropHolder extends DropHolder return _maxLevel; } - public Collection getMonsterIds() + public Set getMonsterIds() { return _monsterIds; } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/item/Henna.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/item/Henna.java index 107656dba9..3fa8d06bc6 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/item/Henna.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/item/Henna.java @@ -17,9 +17,11 @@ package org.l2jmobius.gameserver.model.item; import java.util.ArrayList; -import java.util.HashMap; +import java.util.EnumMap; +import java.util.EnumSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.enums.ClassId; import org.l2jmobius.gameserver.model.StatSet; @@ -34,14 +36,14 @@ public class Henna { private final int _dyeId; private final int _dyeItemId; - private final Map _baseStats = new HashMap<>(); + private final Map _baseStats = new EnumMap<>(BaseStat.class); private final int _wearFee; private final int _wearCount; private final int _cancelFee; private final int _cancelCount; private final int _duration; private final List _skills; - private final List _wearClass; + private final Set _wearClass; public Henna(StatSet set) { @@ -59,7 +61,7 @@ public class Henna _cancelCount = set.getInt("cancel_count"); _duration = set.getInt("duration", -1); _skills = new ArrayList<>(); - _wearClass = new ArrayList<>(); + _wearClass = EnumSet.noneOf(ClassId.class); } /** @@ -147,7 +149,7 @@ public class Henna /** * @return the list with the allowed classes to wear this dye. */ - public List getAllowedWearClass() + public Set getAllowedWearClass() { return _wearClass; } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java index d74b1218d3..5d694e5169 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java @@ -17,9 +17,10 @@ package org.l2jmobius.gameserver.model.item.appearance; import java.time.Duration; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.enums.Race; @@ -47,12 +48,12 @@ public class AppearanceStone private final ArmorType _armorType; private final AppearanceHandType _handType; private final AppearanceMagicType _magicType; - private List _crystalTypes; - private List _targetTypes; - private List _bodyParts; - private List _races; - private List _racesNot; - private List _allVisualIds; + private Set _crystalTypes; + private Set _targetTypes; + private Set _bodyParts; + private Set _races; + private Set _racesNot; + private Set _allVisualIds; public AppearanceStone(StatSet set) { @@ -172,35 +173,35 @@ public class AppearanceStone { if (_crystalTypes == null) { - _crystalTypes = new ArrayList<>(); + _crystalTypes = EnumSet.noneOf(CrystalType.class); } _crystalTypes.add(type); } - public List getCrystalTypes() + public Set getCrystalTypes() { - return _crystalTypes != null ? _crystalTypes : Collections.emptyList(); + return _crystalTypes != null ? _crystalTypes : Collections.emptySet(); } public void addTargetType(AppearanceTargetType type) { if (_targetTypes == null) { - _targetTypes = new ArrayList<>(); + _targetTypes = EnumSet.noneOf(AppearanceTargetType.class); } _targetTypes.add(type); } - public List getTargetTypes() + public Set getTargetTypes() { - return _targetTypes != null ? _targetTypes : Collections.emptyList(); + return _targetTypes != null ? _targetTypes : Collections.emptySet(); } public void addBodyPart(long part) { if (_bodyParts == null) { - _bodyParts = new ArrayList<>(); + _bodyParts = new HashSet<>(); } _bodyParts.add(part); } @@ -209,47 +210,47 @@ public class AppearanceStone { if (_allVisualIds == null) { - _allVisualIds = new ArrayList<>(); + _allVisualIds = new HashSet<>(); } _allVisualIds.add(appearanceHolder); } - public List getVisualIds() + public Set getVisualIds() { - return _allVisualIds != null ? _allVisualIds : Collections.emptyList(); + return _allVisualIds != null ? _allVisualIds : Collections.emptySet(); } - public List getBodyParts() + public Set getBodyParts() { - return _bodyParts != null ? _bodyParts : Collections.emptyList(); + return _bodyParts != null ? _bodyParts : Collections.emptySet(); } public void addRace(Race race) { if (_races == null) { - _races = new ArrayList<>(); + _races = EnumSet.noneOf(Race.class); } _races.add(race); } - public List getRaces() + public Set getRaces() { - return _races != null ? _races : Collections.emptyList(); + return _races != null ? _races : Collections.emptySet(); } public void addRaceNot(Race race) { if (_racesNot == null) { - _racesNot = new ArrayList<>(); + _racesNot = EnumSet.noneOf(Race.class); } _racesNot.add(race); } - public List getRacesNot() + public Set getRacesNot() { - return _racesNot != null ? _racesNot : Collections.emptyList(); + return _racesNot != null ? _racesNot : Collections.emptySet(); } /** @@ -302,7 +303,7 @@ public class AppearanceStone { // Seems like in retail item with already changed appearance, can be changed again without being restored. - final AppearanceTargetType targetType = getTargetTypes().get(0); + final AppearanceTargetType targetType = getTargetTypes().stream().findFirst().get(); switch (targetType) { case NONE: diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java index e8cb83ad95..007afb2d72 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java @@ -16,16 +16,16 @@ */ package org.l2jmobius.gameserver.model.item.enchant; +import java.util.EnumSet; +import java.util.Set; import java.util.logging.Logger; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.item.ItemTemplate; import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.model.item.type.CrystalType; import org.l2jmobius.gameserver.model.item.type.EtcItemType; -import org.l2jmobius.gameserver.model.item.type.ItemType; /** * @author UnAfraid @@ -34,28 +34,29 @@ public abstract class AbstractEnchantItem { protected static final Logger LOGGER = Logger.getLogger(AbstractEnchantItem.class.getName()); - private static final ItemType[] ENCHANT_TYPES = new ItemType[] + private static final Set ENCHANT_TYPES = EnumSet.noneOf(EtcItemType.class); + static { - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM, - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP, - EtcItemType.BLESS_ENCHT_AM, - EtcItemType.BLESS_ENCHT_AM_DOWN, - EtcItemType.BLESS_ENCHT_WP, - EtcItemType.ENCHT_AM, - EtcItemType.ENCHT_WP, - EtcItemType.GIANT_ENCHT_AM, - EtcItemType.GIANT_ENCHT_WP, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.CURSED_ENCHT_AM, - EtcItemType.CURSED_ENCHT_WP, - }; + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.CURSED_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.CURSED_ENCHT_WP); + } private final int _id; private final CrystalType _grade; @@ -74,7 +75,7 @@ public abstract class AbstractEnchantItem { throw new NullPointerException(); } - else if (!CommonUtil.contains(ENCHANT_TYPES, getItem().getItemType())) + else if (!ENCHANT_TYPES.contains(getItem().getItemType())) { throw new IllegalAccessError(); } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/options/OptionDataCategory.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/options/OptionDataCategory.java index dd8d1e4281..4e7856e4a2 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/options/OptionDataCategory.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/options/OptionDataCategory.java @@ -16,9 +16,9 @@ */ package org.l2jmobius.gameserver.model.options; -import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import org.l2jmobius.commons.util.Rnd; @@ -28,10 +28,10 @@ import org.l2jmobius.commons.util.Rnd; public class OptionDataCategory { private final Map _options; - private final List _itemIds; + private final Set _itemIds; private final double _chance; - public OptionDataCategory(Map options, List itemIds, double chance) + public OptionDataCategory(Map options, Set itemIds, double chance) { _options = options; _itemIds = itemIds; @@ -59,7 +59,7 @@ public class OptionDataCategory return result; } - public List getItemIds() + public Set getItemIds() { return _itemIds; } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java index 5ba6755084..18508d0145 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java @@ -24,8 +24,10 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Set; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -184,7 +186,7 @@ public class LongTimeEvent extends Quest final Node maxLevelNode = d.getAttributes().getNamedItem("maxLevel"); final int maxLevel = maxLevelNode == null ? Integer.MAX_VALUE : Integer.parseInt(maxLevelNode.getNodeValue()); final Node monsterIdsNode = d.getAttributes().getNamedItem("monsterIds"); - final List monsterIds = new ArrayList<>(); + final Set monsterIds = new HashSet<>(); if (monsterIdsNode != null) { for (String id : monsterIdsNode.getNodeValue().split(",")) diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/residences/ClanHall.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/residences/ClanHall.java index 0c0a529077..fcc850371b 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/residences/ClanHall.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/residences/ClanHall.java @@ -23,7 +23,9 @@ import java.sql.SQLException; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -61,9 +63,9 @@ public class ClanHall extends AbstractResidence private final int _minBid; final int _lease; private final int _deposit; - private final List _npcs; - private final List _doors; - private final List _teleports; + private final Set _npcs = new HashSet<>(); + private final Set _doors = new HashSet<>(); + private final Set _teleports = new HashSet<>(); private final Location _ownerLocation; private final Location _banishLocation; // Dynamic parameters @@ -85,9 +87,21 @@ public class ClanHall extends AbstractResidence _minBid = params.getInt("minBid"); _lease = params.getInt("lease"); _deposit = params.getInt("deposit"); - _npcs = params.getList("npcList", Integer.class); - _doors = params.getList("doorList", Door.class); - _teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + final List npcs = params.getList("npcList", Integer.class); + if (npcs != null) + { + _npcs.addAll(npcs); + } + final List doors = params.getList("doorList", Door.class); + if (doors != null) + { + _doors.addAll(doors); + } + final List teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + if (teleports != null) + { + _teleports.addAll(teleports); + } _ownerLocation = params.getLocation("owner_loc"); _banishLocation = params.getLocation("banish_loc"); // Set dynamic parameters (from DB) @@ -196,7 +210,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Door} related to this {@link ClanHall}. * @return all {@link Door} related to this {@link ClanHall} */ - public List getDoors() + public Set getDoors() { return _doors; } @@ -205,7 +219,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Npc} related to this {@link ClanHall}. * @return all {@link Npc} related to this {@link ClanHall} */ - public List getNpcs() + public Set getNpcs() { return _npcs; } @@ -324,7 +338,7 @@ public class ClanHall extends AbstractResidence return _banishLocation; } - public List getTeleportList() + public Set getTeleportList() { return _teleports; } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/siege/Castle.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/siege/Castle.java index 0244ddbd3b..210c516669 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/siege/Castle.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/siege/Castle.java @@ -21,8 +21,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.Calendar; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -83,7 +85,7 @@ public class Castle extends AbstractResidence private SiegeZone _zone = null; private ResidenceTeleportZone _teleZone; private Clan _formerOwner = null; - private final List _artefacts = new ArrayList<>(1); + private final Set _artefacts = new HashSet<>(1); private final Map _function = new ConcurrentHashMap<>(); private int _ticketBuyCount = 0; private boolean _isFirstMidVictory = false; @@ -1072,7 +1074,7 @@ public class Castle extends AbstractResidence _artefacts.add(artefact); } - public List getArtefacts() + public Set getArtefacts() { return _artefacts; } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java index 0c79677eae..4ebf954ee5 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.network.serverpackets; -import java.util.List; +import java.util.Set; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.gameserver.data.sql.CharNameTable; @@ -27,19 +27,19 @@ import org.l2jmobius.gameserver.network.OutgoingPackets; */ public class BlockListPacket implements IClientOutgoingPacket { - private final List _playersId; + private final Set _playerIds; - public BlockListPacket(List playersId) + public BlockListPacket(Set playerIds) { - _playersId = playersId; + _playerIds = playerIds; } @Override public boolean write(PacketWriter packet) { OutgoingPackets.BLOCK_LIST.writeId(packet); - packet.writeD(_playersId.size()); - for (int playerId : _playersId) + packet.writeD(_playerIds.size()); + for (int playerId : _playerIds) { packet.writeS(CharNameTable.getInstance().getNameById(playerId)); packet.writeS(""); // memo ? diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java index 8555bb6e86..eb5bfd05d8 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.network.serverpackets; import java.util.List; import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; import org.l2jmobius.commons.network.PacketWriter; @@ -37,7 +38,7 @@ public class ExAcquireSkillInfo implements IClientOutgoingPacket private final int _dualClassLevel; private final long _spCost; private final int _minLevel; - private final List _itemReq; + private final Set _itemReq; private final List _skillRem; /** diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java index 84b5fead76..a163a85735 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java @@ -35,7 +35,7 @@ public class ExChooseShapeShiftingItem implements IClientOutgoingPacket public ExChooseShapeShiftingItem(AppearanceStone stone) { _type = stone.getType(); - _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().get(0); + _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().stream().findFirst().get(); _itemId = stone.getId(); } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/util/DocumentBase.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/util/DocumentBase.java index 28bfbc316c..2ffccdc2ac 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/util/DocumentBase.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/util/DocumentBase.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.util; import java.io.File; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -391,12 +392,12 @@ public abstract class DocumentBase case "races": { final String[] racesVal = a.getNodeValue().split(","); - final Race[] races = new Race[racesVal.length]; + final Set races = EnumSet.noneOf(Race.class); for (int r = 0; r < racesVal.length; r++) { if (racesVal[r] != null) { - races[r] = Race.valueOf(racesVal[r]); + races.add(Race.valueOf(racesVal[r])); } } cond = joinAnd(cond, new ConditionPlayerRace(races)); @@ -673,13 +674,13 @@ public abstract class DocumentBase case "instanceid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final ArrayList array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInstanceId(array)); + cond = joinAnd(cond, new ConditionPlayerInstanceId(set)); break; } case "agathionid": @@ -730,10 +731,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -747,10 +748,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -836,13 +837,13 @@ public abstract class DocumentBase case "insidezoneid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInsideZoneId(array)); + cond = joinAnd(cond, new ConditionPlayerInsideZoneId(set)); break; } case "checkabnormal": @@ -963,13 +964,13 @@ public abstract class DocumentBase case "class_id_restriction": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetClassIdRestriction(array)); + cond = joinAnd(cond, new ConditionTargetClassIdRestriction(set)); break; } case "active_effect_id": @@ -1047,13 +1048,13 @@ public abstract class DocumentBase case "npcid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetNpcId(array)); + cond = joinAnd(cond, new ConditionTargetNpcId(set)); break; } case "npctype": diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/bypasshandlers/Link.java b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/bypasshandlers/Link.java index 5097e77f56..2cb1581627 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/bypasshandlers/Link.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/bypasshandlers/Link.java @@ -16,7 +16,9 @@ */ package handlers.bypasshandlers; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.HashSet; +import java.util.Set; + import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.handler.IBypassHandler; import org.l2jmobius.gameserver.model.actor.Creature; @@ -31,28 +33,29 @@ public class Link implements IBypassHandler "Link" }; - private static final String[] VALID_LINKS = + private static final Set VALID_LINKS = new HashSet<>(); + static { - "common/craft_01.htm", - "common/craft_02.htm", - "common/runes_01.htm", - "common/skill_enchant_help_01.htm", - "common/skill_enchant_help_02.htm", - "common/skill_enchant_help_03.htm", - "default/BlessingOfProtection.htm", - "default/SupportMagic.htm", - "fisherman/fishing_manual001.htm", - "fisherman/fishing_manual002.htm", - "fisherman/fishing_manual003.htm", - "fisherman/fishing_manual004.htm", - "fisherman/fishing_manual005.htm", - "fortress/foreman.htm", - "petmanager/evolve.htm", - "petmanager/exchange.htm", - "petmanager/instructions.htm", - "warehouse/clanwh.htm", - "warehouse/privatewh.htm", - }; + VALID_LINKS.add("common/craft_01.htm"); + VALID_LINKS.add("common/craft_02.htm"); + VALID_LINKS.add("common/runes_01.htm"); + VALID_LINKS.add("common/skill_enchant_help_01.htm"); + VALID_LINKS.add("common/skill_enchant_help_02.htm"); + VALID_LINKS.add("common/skill_enchant_help_03.htm"); + VALID_LINKS.add("default/BlessingOfProtection.htm"); + VALID_LINKS.add("default/SupportMagic.htm"); + VALID_LINKS.add("fisherman/fishing_manual001.htm"); + VALID_LINKS.add("fisherman/fishing_manual002.htm"); + VALID_LINKS.add("fisherman/fishing_manual003.htm"); + VALID_LINKS.add("fisherman/fishing_manual004.htm"); + VALID_LINKS.add("fisherman/fishing_manual008.htm"); + VALID_LINKS.add("fortress/foreman.htm"); + VALID_LINKS.add("petmanager/evolve.htm"); + VALID_LINKS.add("petmanager/exchange.htm"); + VALID_LINKS.add("petmanager/instructions.htm"); + VALID_LINKS.add("warehouse/clanwh.htm"); + VALID_LINKS.add("warehouse/privatewh.htm"); + } @Override public boolean useBypass(String command, Player player, Creature target) @@ -70,12 +73,13 @@ public class Link implements IBypassHandler return false; } - String content = CommonUtil.contains(VALID_LINKS, htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; + String content = VALID_LINKS.contains(htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; // Precaution. if (htmlPath.startsWith("teleporter/") && !(player.getTarget() instanceof Teleporter)) { content = null; } + final NpcHtmlMessage html = new NpcHtmlMessage(target != null ? target.getObjectId() : 0); if (content != null) { diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java index b18ea0d506..171c3003dd 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java @@ -16,8 +16,9 @@ */ package handlers.dailymissionhandlers; -import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.Config; import org.l2jmobius.gameserver.enums.DailyMissionStatus; @@ -41,7 +42,7 @@ public class MonsterDailyMissionHandler extends AbstractDailyMissionHandler private final int _amount; private final int _minLevel; private final int _maxLevel; - private final List _ids = new ArrayList<>(); + private final Set _ids = new HashSet<>(); public MonsterDailyMissionHandler(DailyMissionDataHolder holder) { diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/itemhandlers/PetFood.java b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/itemhandlers/PetFood.java index 3c5572d4ec..8b908ea095 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/itemhandlers/PetFood.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/itemhandlers/PetFood.java @@ -17,6 +17,7 @@ package handlers.itemhandlers; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.PetDataTable; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -79,7 +80,7 @@ public class PetFood implements IItemHandler final Player player = activeChar.getActingPlayer(); if (player.isMounted()) { - final List foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); + final Set foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); if (foodIds.contains(item.getId()) && player.destroyItem("Consume", item.getObjectId(), 1, null, false)) { player.broadcastPacket(new MagicSkillUse(player, player, skillId, skillLevel, 0, 0)); diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java index 2ad282f683..99f45fbb41 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.ClanHallData; import org.l2jmobius.gameserver.model.StatSet; @@ -32,12 +33,12 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpCheckResidenceSkillCondition implements ISkillCondition { - private final List _residencesId; + private final Set _residencesId = new HashSet<>(); private final boolean _isWithin; public OpCheckResidenceSkillCondition(StatSet params) { - _residencesId = params.getList("residencesId", Integer.class); + _residencesId.addAll(params.getList("residencesId", Integer.class)); _isWithin = params.getBoolean("isWithin"); } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java index fc2934423b..4a8282d988 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java @@ -16,9 +16,9 @@ */ package handlers.skillconditionhandlers; -import java.util.ArrayList; -import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -28,18 +28,18 @@ import org.l2jmobius.gameserver.model.skill.ISkillCondition; import org.l2jmobius.gameserver.model.skill.Skill; /** - * @author UnAfraid + * @author UnAfraid, Mobius */ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition { - private final List _npcIds = new ArrayList<>(); + private final Set _npcIds = new HashSet<>(); public OpNeedSummonOrPetSkillCondition(StatSet params) { - final List npcIds = params.getList("npcIds", String.class); + final List npcIds = params.getList("npcIds", Integer.class); if (npcIds != null) { - npcIds.stream().map(Integer::valueOf).forEach(_npcIds::add); + _npcIds.addAll(npcIds); } } @@ -47,7 +47,19 @@ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition public boolean canUse(Creature caster, Skill skill, WorldObject target) { final Summon pet = caster.getPet(); - final Collection summons = caster.getServitors().values(); - return ((pet != null) && _npcIds.stream().anyMatch(npcId -> npcId == pet.getId())) || summons.stream().anyMatch(summon -> _npcIds.contains(summon.getId())); + if ((pet != null) && _npcIds.contains(pet.getId())) + { + return true; + } + + for (Summon summon : caster.getServitors().values()) + { + if (_npcIds.contains(summon.getId())) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java index 8541bc62b4..ef81b291d4 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,11 +30,11 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetDoorSkillCondition implements ISkillCondition { - private final List _doorIds; + private final Set _doorIds = new HashSet<>(); public OpTargetDoorSkillCondition(StatSet params) { - _doorIds = params.getList("doorIds", Integer.class); + _doorIds.addAll(params.getList("doorIds", Integer.class)); } @Override diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java index 3ce4145703..0ccd571e19 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,17 +30,17 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetNpcSkillCondition implements ISkillCondition { - private final List _npcId; + private final Set _npcIds = new HashSet<>(); public OpTargetNpcSkillCondition(StatSet params) { - _npcId = params.getList("npcIds", Integer.class); + _npcIds.addAll(params.getList("npcIds", Integer.class)); } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget(); - return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId()); + return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcIds.contains(actualTarget.getId()); } } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/instances/AbstractInstance.java b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/instances/AbstractInstance.java index d485c2c36d..4a0a3d35d4 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/instances/AbstractInstance.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/instances/AbstractInstance.java @@ -16,9 +16,10 @@ */ package instances; +import java.util.HashSet; import java.util.List; +import java.util.Set; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.enums.InstanceReenterType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.instancemanager.InstanceManager; @@ -40,25 +41,29 @@ import ai.AbstractNpcAI; */ public abstract class AbstractInstance extends AbstractNpcAI { - private final int[] _templateIds; + private final Set _templateIds = new HashSet<>(); - public AbstractInstance(int... templateId) + public AbstractInstance(int... templateIds) { - if (templateId.length == 0) + if (templateIds.length == 0) { throw new IllegalStateException("No template ids were provided!"); } - _templateIds = templateId; + + for (int templateId : templateIds) + { + _templateIds.add(templateId); + } } - public int[] getTemplateId() + public Set getTemplateId() { return _templateIds; } public boolean isInInstance(Instance instance) { - return (instance != null) && CommonUtil.contains(_templateIds, instance.getTemplateId()); + return (instance != null) && _templateIds.contains(instance.getTemplateId()); } /** diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/Config.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/Config.java index ac9acc3107..0e1caed230 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/Config.java @@ -288,7 +288,7 @@ public class Config public static boolean AUTO_LOOT_SLOT_LIMIT; public static int LOOT_RAIDS_PRIVILEGE_INTERVAL; public static int LOOT_RAIDS_PRIVILEGE_CC_SIZE; - public static List AUTO_LOOT_ITEM_IDS; + public static Set AUTO_LOOT_ITEM_IDS; public static boolean ENABLE_KEYBOARD_MOVEMENT; public static int UNSTUCK_INTERVAL; public static int TELEPORT_WATCHDOG_TIMEOUT; @@ -477,7 +477,7 @@ public class Config public static boolean ALLOW_DISCARDITEM; public static int AUTODESTROY_ITEM_AFTER; public static int HERB_AUTO_DESTROY_TIME; - public static List LIST_PROTECTED_ITEMS; + public static Set LIST_PROTECTED_ITEMS; public static boolean DATABASE_CLEAN_UP; public static int CHAR_DATA_STORE_INTERVAL; public static int CLAN_VARIABLES_STORE_INTERVAL; @@ -568,7 +568,7 @@ public class Config public static boolean ALT_OLY_LOG_FIGHTS; public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS; public static boolean ALT_OLY_ANNOUNCE_GAMES; - public static List LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(); + public static Set LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(); public static int ALT_OLY_WEAPON_ENCHANT_LIMIT; public static int ALT_OLY_ARMOR_ENCHANT_LIMIT; public static int ALT_OLY_WAIT_TIME; @@ -1196,9 +1196,9 @@ public class Config public static int AUTO_CP_PERCENTAGE; public static int AUTO_HP_PERCENTAGE; public static int AUTO_MP_PERCENTAGE; - public static List AUTO_CP_ITEM_IDS; - public static List AUTO_HP_ITEM_IDS; - public static List AUTO_MP_ITEM_IDS; + public static Set AUTO_CP_ITEM_IDS; + public static Set AUTO_HP_ITEM_IDS; + public static Set AUTO_MP_ITEM_IDS; public static boolean CUSTOM_STARTING_LOC; public static int CUSTOM_STARTING_LOC_X; public static int CUSTOM_STARTING_LOC_Y; @@ -1208,7 +1208,7 @@ public class Config public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; public static int MOB_MIN_SPAWN_RANGE; public static int MOB_MAX_SPAWN_RANGE; - public static List MOBS_LIST_NOT_RANDOM; + public static Set MOBS_LIST_NOT_RANDOM; public static boolean FREE_JUMPS_FOR_ALL; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; @@ -1227,7 +1227,7 @@ public class Config public static boolean COMMUNITY_PREMIUM_SYSTEM_ENABLED; public static int COMMUNITY_PREMIUM_COIN_ID; public static int COMMUNITY_PREMIUM_PRICE_PER_DAY; - public static List COMMUNITY_AVAILABLE_BUFFS; + public static Set COMMUNITY_AVAILABLE_BUFFS; public static Map COMMUNITY_AVAILABLE_TELEPORTS; public static boolean CUSTOM_DEPOSITABLE_ENABLED; public static boolean CUSTOM_DEPOSITABLE_QUEST_ITEMS; @@ -1877,7 +1877,7 @@ public class Config LOOT_RAIDS_PRIVILEGE_INTERVAL = characterConfig.getInt("RaidLootRightsInterval", 900) * 1000; LOOT_RAIDS_PRIVILEGE_CC_SIZE = characterConfig.getInt("RaidLootRightsCCSize", 45); final String[] autoLootItemIds = characterConfig.getString("AutoLootItemIds", "0").split(","); - AUTO_LOOT_ITEM_IDS = new ArrayList<>(autoLootItemIds.length); + AUTO_LOOT_ITEM_IDS = new HashSet<>(autoLootItemIds.length); for (String item : autoLootItemIds) { Integer itm = 0; @@ -2046,7 +2046,7 @@ public class Config AUTODESTROY_ITEM_AFTER = generalConfig.getInt("AutoDestroyDroppedItemAfter", 600); HERB_AUTO_DESTROY_TIME = generalConfig.getInt("AutoDestroyHerbTime", 60) * 1000; final String[] split = generalConfig.getString("ListOfProtectedItems", "0").split(","); - LIST_PROTECTED_ITEMS = new ArrayList<>(split.length); + LIST_PROTECTED_ITEMS = new HashSet<>(split.length); for (String id : split) { LIST_PROTECTED_ITEMS.add(Integer.parseInt(id)); @@ -2461,7 +2461,7 @@ public class Config if (!olyRestrictedItems.isEmpty()) { final String[] olyRestrictedItemsSplit = olyRestrictedItems.split(","); - LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(olyRestrictedItemsSplit.length); + LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(olyRestrictedItemsSplit.length); for (String id : olyRestrictedItemsSplit) { LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id)); @@ -2576,17 +2576,17 @@ public class Config AUTO_CP_PERCENTAGE = autoPotionsConfig.getInt("AutoCpPercentage", 70); AUTO_HP_PERCENTAGE = autoPotionsConfig.getInt("AutoHpPercentage", 70); AUTO_MP_PERCENTAGE = autoPotionsConfig.getInt("AutoMpPercentage", 70); - AUTO_CP_ITEM_IDS = new ArrayList<>(); + AUTO_CP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoCpItemIds", "0").split(",")) { AUTO_CP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_HP_ITEM_IDS = new ArrayList<>(); + AUTO_HP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoHpItemIds", "0").split(",")) { AUTO_HP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_MP_ITEM_IDS = new ArrayList<>(); + AUTO_MP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoMpItemIds", "0").split(",")) { AUTO_MP_ITEM_IDS.add(Integer.parseInt(s)); @@ -3196,7 +3196,7 @@ public class Config COMMUNITY_PREMIUM_COIN_ID = communityBoardConfig.getInt("CommunityPremiumBuyCoinId", 57); COMMUNITY_PREMIUM_PRICE_PER_DAY = communityBoardConfig.getInt("CommunityPremiumPricePerDay", 1000000); final String[] allowedBuffs = communityBoardConfig.getString("CommunityAvailableBuffs", "").split(","); - COMMUNITY_AVAILABLE_BUFFS = new ArrayList<>(allowedBuffs.length); + COMMUNITY_AVAILABLE_BUFFS = new HashSet<>(allowedBuffs.length); for (String s : allowedBuffs) { COMMUNITY_AVAILABLE_BUFFS.add(Integer.parseInt(s)); @@ -3480,7 +3480,7 @@ public class Config if (ENABLE_RANDOM_MONSTER_SPAWNS) { final String[] mobsIds = randomSpawnsConfig.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); - MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + MOBS_LIST_NOT_RANDOM = new HashSet<>(mobsIds.length); for (String id : mobsIds) { MOBS_LIST_NOT_RANDOM.add(Integer.parseInt(id)); diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java index d6e0183c6f..c3977185b4 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java @@ -202,8 +202,7 @@ public class ClanHallData implements IXmlReader final Door door = DoorData.getInstance().getDoor(doorId); for (ClanHall ch : _clanHalls.values()) { - final List doors = ch.getDoors(); - if ((doors != null) && doors.contains(door)) + if (ch.getDoors().contains(door)) { return ch; } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java index 6aa0a1fdde..fb395b9e2d 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java @@ -17,10 +17,10 @@ package org.l2jmobius.gameserver.data.xml; import java.io.File; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -42,7 +42,7 @@ public class FakePlayerData implements IXmlReader private final Map _fakePlayerInfos = new HashMap<>(); private final Map _fakePlayerNames = new HashMap<>(); private final Map _fakePlayerIds = new HashMap<>(); - private final List _talkableFakePlayerNames = new ArrayList<>(); + private final Set _talkableFakePlayerNames = new HashSet<>(); protected FakePlayerData() { diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/data/xml/VariationData.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/data/xml/VariationData.java index c29a10baa2..079f5b3077 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/data/xml/VariationData.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/data/xml/VariationData.java @@ -20,8 +20,10 @@ import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Logger; @@ -114,14 +116,11 @@ public class VariationData implements IXmlReader }); // Support for specific item ids. - final List itemIds = new ArrayList<>(); + final Set itemIds = new HashSet<>(); forEach(categoryNode, "item", optionNode -> { final int itemId = parseInteger(optionNode.getAttributes(), "id"); - if (!itemIds.contains(itemId)) - { - itemIds.add(itemId); - } + itemIds.add(itemId); }); forEach(categoryNode, "items", optionNode -> { @@ -129,10 +128,7 @@ public class VariationData implements IXmlReader final int toId = parseInteger(optionNode.getAttributes(), "to"); for (int id = fromId; id <= toId; id++) { - if (!itemIds.contains(id)) - { - itemIds.add(id); - } + itemIds.add(id); } }); diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java index d335b95954..1122d7b9ba 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java @@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -49,7 +51,7 @@ import org.l2jmobius.gameserver.util.Util; public class SellBuffsManager implements IXmlReader { private static final Logger LOGGER = Logger.getLogger(SellBuffsManager.class.getName()); - private static final List ALLOWED_BUFFS = new ArrayList<>(); + private static final Set ALLOWED_BUFFS = new HashSet<>(); private static final String HTML_FOLDER = "data/html/mods/SellBuffs/"; protected SellBuffsManager() @@ -76,11 +78,7 @@ public class SellBuffsManager implements IXmlReader { final Element elem = (Element) node.item(i); final int skillId = Integer.parseInt(elem.getAttribute("id")); - - if (!ALLOWED_BUFFS.contains(skillId)) - { - ALLOWED_BUFFS.add(skillId); - } + ALLOWED_BUFFS.add(skillId); } } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java index b10f75ef3d..1e45a21319 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java @@ -19,8 +19,10 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; @@ -67,7 +69,7 @@ public class WalkingManager implements IXmlReader public static final byte REPEAT_TELE_FIRST = 2; public static final byte REPEAT_RANDOM = 3; - private final List _targetedNpcIds = new ArrayList<>(); + private final Set _targetedNpcIds = new HashSet<>(); private final Map _routes = new HashMap<>(); // all available routes private final Map _activeRoutes = new HashMap<>(); // each record represents NPC, moving by predefined route from _routes, and moving progress private final Map _routesToAttach = new HashMap<>(); // each record represents NPC and all available routes for it diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/BlockList.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/BlockList.java index d9ef2e01fb..984f05b22d 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/BlockList.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/BlockList.java @@ -19,9 +19,9 @@ package org.l2jmobius.gameserver.model; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -36,10 +36,11 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; public class BlockList { private static final Logger LOGGER = Logger.getLogger(BlockList.class.getName()); - private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); + + private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); private final Player _owner; - private List _blockList; + private Set _blockList; public BlockList(Player owner) { @@ -68,9 +69,9 @@ public class BlockList OFFLINE_LIST.put(_owner.getObjectId(), _blockList); } - private static List loadList(int objId) + private static Set loadList(int objId) { - final List list = new ArrayList<>(); + final Set list = new HashSet<>(); try (Connection con = DatabaseFactory.getConnection(); PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1")) { @@ -158,7 +159,7 @@ public class BlockList _owner.setMessageRefusal(value); } - private List getBlockList() + private Set getBlockList() { return _blockList; } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/PetData.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/PetData.java index 13c808aac7..05421daeae 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/PetData.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/PetData.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; import org.l2jmobius.gameserver.enums.EvolveLevel; @@ -41,7 +43,7 @@ public class PetData private int _minLevel = Byte.MAX_VALUE; private int _maxLevel = 0; private boolean _syncLevel = false; - private final List _food = new ArrayList<>(); + private final Set _food = new HashSet<>(); private final int _petType; private final int _index; private final int _type; @@ -157,7 +159,7 @@ public class PetData /** * @return the pet's food list. */ - public List getFood() + public Set getFood() { return _food; } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/SkillLearn.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/SkillLearn.java index a69d30f105..3d5704b5f2 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/SkillLearn.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/SkillLearn.java @@ -16,9 +16,8 @@ */ package org.l2jmobius.gameserver.model; -import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashSet; -import java.util.List; import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -40,12 +39,12 @@ public class SkillLearn private final int _getDualClassLevel; private final boolean _autoGet; private final long _levelUpSp; - private final List _requiredItems = new ArrayList<>(); - private final List _races = new ArrayList<>(); - private final List _preReqSkills = new ArrayList<>(); + private final Set _requiredItems = new HashSet<>(1); + private final Set _races = EnumSet.noneOf(Race.class); + private final Set _preReqSkills = new HashSet<>(1); private SocialClass _socialClass; private final boolean _residenceSkill; - private final List _residenceIds = new ArrayList<>(); + private final Set _residenceIds = new HashSet<>(1); private final boolean _learnedByNpc; private final boolean _learnedByFS; private final Set _removeSkills = new HashSet<>(1); @@ -133,9 +132,9 @@ public class SkillLearn } /** - * @return the list with the item holders required to acquire this skill. + * @return the set with the item holders required to acquire this skill. */ - public List getRequiredItems() + public Set getRequiredItems() { return _requiredItems; } @@ -150,9 +149,9 @@ public class SkillLearn } /** - * @return a list with the races that can acquire this skill. + * @return a set with the races that can acquire this skill. */ - public List getRaces() + public Set getRaces() { return _races; } @@ -167,9 +166,9 @@ public class SkillLearn } /** - * @return the list of skill holders required to acquire this skill. + * @return the set of skill holders required to acquire this skill. */ - public List getPreReqSkills() + public Set getPreReqSkills() { return _preReqSkills; } @@ -212,9 +211,9 @@ public class SkillLearn } /** - * @return a list with the Ids where this skill is available. + * @return a set with the Ids where this skill is available. */ - public List getResidenceIds() + public Set getResidenceIds() { return _residenceIds; } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java index 9825cc04fd..8668ed8a0c 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java @@ -263,7 +263,7 @@ public class Pet extends Summon broadcastStatusUpdate(); - final List foodIds = getPetData().getFood(); + final Set foodIds = getPetData().getFood(); if (foodIds.isEmpty()) { if (isUncontrollable()) diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java index 1a97730017..08104cb5d1 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java @@ -16,8 +16,8 @@ */ package org.l2jmobius.gameserver.model.actor.instance; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import org.l2jmobius.commons.threads.ThreadPool; @@ -57,7 +57,7 @@ public class Trap extends Npc private boolean _isTriggered; private final int _lifeTime; private Player _owner; - private final List _playersWhoDetectedMe = new ArrayList<>(); + private final Set _playersWhoDetectedMe = new HashSet<>(); private final SkillHolder _skill; private int _remainingTime; // Tasks diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java index 71ef076212..3ba8c20a9b 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor.tasks.player; -import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -69,11 +69,12 @@ public class PetFeedTask implements Runnable _player.sendPacket(SystemMessageId.YOU_ARE_OUT_OF_FEED_MOUNT_STATUS_CANCELED); } - final List foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); + final Set foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); if (foodIds.isEmpty()) { return; } + Item food = null; for (int id : foodIds) { diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java index 50d2a821c3..2611b5f121 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.actor.Creature; @@ -29,9 +29,9 @@ import org.l2jmobius.gameserver.model.zone.ZoneType; */ public class ConditionPlayerInsideZoneId extends Condition { - private final List _zones; + private final Set _zones; - public ConditionPlayerInsideZoneId(List zones) + public ConditionPlayerInsideZoneId(Set zones) { _zones = zones; } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java index c15065eca2..d644f663f5 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Player; @@ -29,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerInstanceId extends Condition { - private final List _instanceIds; + private final Set _instanceIds; /** * Instantiates a new condition player instance id. * @param instanceIds the instance ids */ - public ConditionPlayerInstanceId(List instanceIds) + public ConditionPlayerInstanceId(Set instanceIds) { _instanceIds = instanceIds; } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java index 14d61089ed..7c375ec45e 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -28,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerRace extends Condition { - private final Race[] _races; + private final Set _races; /** * Instantiates a new condition player race. * @param races the list containing the allowed races. */ - public ConditionPlayerRace(Race[] races) + public ConditionPlayerRace(Set races) { _races = races; } @@ -46,6 +47,6 @@ public class ConditionPlayerRace extends Condition { return false; } - return CommonUtil.contains(_races, effector.getActingPlayer().getRace()); + return _races.contains(effector.getActingPlayer().getRace()); } } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java index 0f54766571..0b326e3f40 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId())) + if (_npcIds.contains(target.getId())) { existNpc = true; break; diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java index c5c9b5ff0e..db64b6bd7b 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromSummonedNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromSummonedNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromSummonedNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromSummonedNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId()) && (effector == target.getSummoner())) + if (_npcIds.contains(target.getId()) && (effector == target.getSummoner())) { existNpc = true; break; diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java index a3fb0f5374..a47b4b4983 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetClassIdRestriction extends Condition { - private final List _classIds; + private final Set _classIds; /** * Instantiates a new condition target class id restriction. * @param classId the class id */ - public ConditionTargetClassIdRestriction(List classId) + public ConditionTargetClassIdRestriction(Set classId) { _classIds = classId; } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java index 82b1bd5877..9bb694f4ef 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetNpcId extends Condition { - private final List _npcIds; + private final Set _npcIds; /** * Instantiates a new condition target npc id. * @param npcIds the npc ids */ - public ConditionTargetNpcId(List npcIds) + public ConditionTargetNpcId(Set npcIds) { _npcIds = npcIds; } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java index f26329bc21..5c86f26ae5 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.holders; -import java.util.Collection; +import java.util.Set; /** * @author Mobius @@ -25,9 +25,9 @@ public class EventDropHolder extends DropHolder { private final int _minLevel; private final int _maxLevel; - private final Collection _monsterIds; + private final Set _monsterIds; - public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Collection monsterIds) + public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Set monsterIds) { super(null, itemId, min, max, chance); _minLevel = minLevel; @@ -45,7 +45,7 @@ public class EventDropHolder extends DropHolder return _maxLevel; } - public Collection getMonsterIds() + public Set getMonsterIds() { return _monsterIds; } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/item/Henna.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/item/Henna.java index 107656dba9..3fa8d06bc6 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/item/Henna.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/item/Henna.java @@ -17,9 +17,11 @@ package org.l2jmobius.gameserver.model.item; import java.util.ArrayList; -import java.util.HashMap; +import java.util.EnumMap; +import java.util.EnumSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.enums.ClassId; import org.l2jmobius.gameserver.model.StatSet; @@ -34,14 +36,14 @@ public class Henna { private final int _dyeId; private final int _dyeItemId; - private final Map _baseStats = new HashMap<>(); + private final Map _baseStats = new EnumMap<>(BaseStat.class); private final int _wearFee; private final int _wearCount; private final int _cancelFee; private final int _cancelCount; private final int _duration; private final List _skills; - private final List _wearClass; + private final Set _wearClass; public Henna(StatSet set) { @@ -59,7 +61,7 @@ public class Henna _cancelCount = set.getInt("cancel_count"); _duration = set.getInt("duration", -1); _skills = new ArrayList<>(); - _wearClass = new ArrayList<>(); + _wearClass = EnumSet.noneOf(ClassId.class); } /** @@ -147,7 +149,7 @@ public class Henna /** * @return the list with the allowed classes to wear this dye. */ - public List getAllowedWearClass() + public Set getAllowedWearClass() { return _wearClass; } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java index d74b1218d3..5d694e5169 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java @@ -17,9 +17,10 @@ package org.l2jmobius.gameserver.model.item.appearance; import java.time.Duration; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.enums.Race; @@ -47,12 +48,12 @@ public class AppearanceStone private final ArmorType _armorType; private final AppearanceHandType _handType; private final AppearanceMagicType _magicType; - private List _crystalTypes; - private List _targetTypes; - private List _bodyParts; - private List _races; - private List _racesNot; - private List _allVisualIds; + private Set _crystalTypes; + private Set _targetTypes; + private Set _bodyParts; + private Set _races; + private Set _racesNot; + private Set _allVisualIds; public AppearanceStone(StatSet set) { @@ -172,35 +173,35 @@ public class AppearanceStone { if (_crystalTypes == null) { - _crystalTypes = new ArrayList<>(); + _crystalTypes = EnumSet.noneOf(CrystalType.class); } _crystalTypes.add(type); } - public List getCrystalTypes() + public Set getCrystalTypes() { - return _crystalTypes != null ? _crystalTypes : Collections.emptyList(); + return _crystalTypes != null ? _crystalTypes : Collections.emptySet(); } public void addTargetType(AppearanceTargetType type) { if (_targetTypes == null) { - _targetTypes = new ArrayList<>(); + _targetTypes = EnumSet.noneOf(AppearanceTargetType.class); } _targetTypes.add(type); } - public List getTargetTypes() + public Set getTargetTypes() { - return _targetTypes != null ? _targetTypes : Collections.emptyList(); + return _targetTypes != null ? _targetTypes : Collections.emptySet(); } public void addBodyPart(long part) { if (_bodyParts == null) { - _bodyParts = new ArrayList<>(); + _bodyParts = new HashSet<>(); } _bodyParts.add(part); } @@ -209,47 +210,47 @@ public class AppearanceStone { if (_allVisualIds == null) { - _allVisualIds = new ArrayList<>(); + _allVisualIds = new HashSet<>(); } _allVisualIds.add(appearanceHolder); } - public List getVisualIds() + public Set getVisualIds() { - return _allVisualIds != null ? _allVisualIds : Collections.emptyList(); + return _allVisualIds != null ? _allVisualIds : Collections.emptySet(); } - public List getBodyParts() + public Set getBodyParts() { - return _bodyParts != null ? _bodyParts : Collections.emptyList(); + return _bodyParts != null ? _bodyParts : Collections.emptySet(); } public void addRace(Race race) { if (_races == null) { - _races = new ArrayList<>(); + _races = EnumSet.noneOf(Race.class); } _races.add(race); } - public List getRaces() + public Set getRaces() { - return _races != null ? _races : Collections.emptyList(); + return _races != null ? _races : Collections.emptySet(); } public void addRaceNot(Race race) { if (_racesNot == null) { - _racesNot = new ArrayList<>(); + _racesNot = EnumSet.noneOf(Race.class); } _racesNot.add(race); } - public List getRacesNot() + public Set getRacesNot() { - return _racesNot != null ? _racesNot : Collections.emptyList(); + return _racesNot != null ? _racesNot : Collections.emptySet(); } /** @@ -302,7 +303,7 @@ public class AppearanceStone { // Seems like in retail item with already changed appearance, can be changed again without being restored. - final AppearanceTargetType targetType = getTargetTypes().get(0); + final AppearanceTargetType targetType = getTargetTypes().stream().findFirst().get(); switch (targetType) { case NONE: diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java index e8cb83ad95..007afb2d72 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java @@ -16,16 +16,16 @@ */ package org.l2jmobius.gameserver.model.item.enchant; +import java.util.EnumSet; +import java.util.Set; import java.util.logging.Logger; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.item.ItemTemplate; import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.model.item.type.CrystalType; import org.l2jmobius.gameserver.model.item.type.EtcItemType; -import org.l2jmobius.gameserver.model.item.type.ItemType; /** * @author UnAfraid @@ -34,28 +34,29 @@ public abstract class AbstractEnchantItem { protected static final Logger LOGGER = Logger.getLogger(AbstractEnchantItem.class.getName()); - private static final ItemType[] ENCHANT_TYPES = new ItemType[] + private static final Set ENCHANT_TYPES = EnumSet.noneOf(EtcItemType.class); + static { - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM, - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP, - EtcItemType.BLESS_ENCHT_AM, - EtcItemType.BLESS_ENCHT_AM_DOWN, - EtcItemType.BLESS_ENCHT_WP, - EtcItemType.ENCHT_AM, - EtcItemType.ENCHT_WP, - EtcItemType.GIANT_ENCHT_AM, - EtcItemType.GIANT_ENCHT_WP, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.CURSED_ENCHT_AM, - EtcItemType.CURSED_ENCHT_WP, - }; + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.CURSED_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.CURSED_ENCHT_WP); + } private final int _id; private final CrystalType _grade; @@ -74,7 +75,7 @@ public abstract class AbstractEnchantItem { throw new NullPointerException(); } - else if (!CommonUtil.contains(ENCHANT_TYPES, getItem().getItemType())) + else if (!ENCHANT_TYPES.contains(getItem().getItemType())) { throw new IllegalAccessError(); } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/options/OptionDataCategory.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/options/OptionDataCategory.java index dd8d1e4281..4e7856e4a2 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/options/OptionDataCategory.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/options/OptionDataCategory.java @@ -16,9 +16,9 @@ */ package org.l2jmobius.gameserver.model.options; -import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import org.l2jmobius.commons.util.Rnd; @@ -28,10 +28,10 @@ import org.l2jmobius.commons.util.Rnd; public class OptionDataCategory { private final Map _options; - private final List _itemIds; + private final Set _itemIds; private final double _chance; - public OptionDataCategory(Map options, List itemIds, double chance) + public OptionDataCategory(Map options, Set itemIds, double chance) { _options = options; _itemIds = itemIds; @@ -59,7 +59,7 @@ public class OptionDataCategory return result; } - public List getItemIds() + public Set getItemIds() { return _itemIds; } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java index 5ba6755084..18508d0145 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java @@ -24,8 +24,10 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Set; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -184,7 +186,7 @@ public class LongTimeEvent extends Quest final Node maxLevelNode = d.getAttributes().getNamedItem("maxLevel"); final int maxLevel = maxLevelNode == null ? Integer.MAX_VALUE : Integer.parseInt(maxLevelNode.getNodeValue()); final Node monsterIdsNode = d.getAttributes().getNamedItem("monsterIds"); - final List monsterIds = new ArrayList<>(); + final Set monsterIds = new HashSet<>(); if (monsterIdsNode != null) { for (String id : monsterIdsNode.getNodeValue().split(",")) diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/residences/ClanHall.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/residences/ClanHall.java index 57aa313704..2fb931a64c 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/residences/ClanHall.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/residences/ClanHall.java @@ -23,7 +23,9 @@ import java.sql.SQLException; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -61,9 +63,9 @@ public class ClanHall extends AbstractResidence private final int _minBid; final int _lease; private final int _deposit; - private final List _npcs; - private final List _doors; - private final List _teleports; + private final Set _npcs = new HashSet<>(); + private final Set _doors = new HashSet<>(); + private final Set _teleports = new HashSet<>(); private final Location _ownerLocation; private final Location _banishLocation; // Dynamic parameters @@ -85,9 +87,21 @@ public class ClanHall extends AbstractResidence _minBid = params.getInt("minBid"); _lease = params.getInt("lease"); _deposit = params.getInt("deposit"); - _npcs = params.getList("npcList", Integer.class); - _doors = params.getList("doorList", Door.class); - _teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + final List npcs = params.getList("npcList", Integer.class); + if (npcs != null) + { + _npcs.addAll(npcs); + } + final List doors = params.getList("doorList", Door.class); + if (doors != null) + { + _doors.addAll(doors); + } + final List teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + if (teleports != null) + { + _teleports.addAll(teleports); + } _ownerLocation = params.getLocation("owner_loc"); _banishLocation = params.getLocation("banish_loc"); // Set dynamic parameters (from DB) @@ -196,7 +210,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Door} related to this {@link ClanHall}. * @return all {@link Door} related to this {@link ClanHall} */ - public List getDoors() + public Set getDoors() { return _doors; } @@ -205,7 +219,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Npc} related to this {@link ClanHall}. * @return all {@link Npc} related to this {@link ClanHall} */ - public List getNpcs() + public Set getNpcs() { return _npcs; } @@ -324,7 +338,7 @@ public class ClanHall extends AbstractResidence return _banishLocation; } - public List getTeleportList() + public Set getTeleportList() { return _teleports; } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/siege/Castle.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/siege/Castle.java index 0244ddbd3b..210c516669 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/siege/Castle.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/siege/Castle.java @@ -21,8 +21,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.Calendar; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -83,7 +85,7 @@ public class Castle extends AbstractResidence private SiegeZone _zone = null; private ResidenceTeleportZone _teleZone; private Clan _formerOwner = null; - private final List _artefacts = new ArrayList<>(1); + private final Set _artefacts = new HashSet<>(1); private final Map _function = new ConcurrentHashMap<>(); private int _ticketBuyCount = 0; private boolean _isFirstMidVictory = false; @@ -1072,7 +1074,7 @@ public class Castle extends AbstractResidence _artefacts.add(artefact); } - public List getArtefacts() + public Set getArtefacts() { return _artefacts; } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java index 0c79677eae..4ebf954ee5 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.network.serverpackets; -import java.util.List; +import java.util.Set; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.gameserver.data.sql.CharNameTable; @@ -27,19 +27,19 @@ import org.l2jmobius.gameserver.network.OutgoingPackets; */ public class BlockListPacket implements IClientOutgoingPacket { - private final List _playersId; + private final Set _playerIds; - public BlockListPacket(List playersId) + public BlockListPacket(Set playerIds) { - _playersId = playersId; + _playerIds = playerIds; } @Override public boolean write(PacketWriter packet) { OutgoingPackets.BLOCK_LIST.writeId(packet); - packet.writeD(_playersId.size()); - for (int playerId : _playersId) + packet.writeD(_playerIds.size()); + for (int playerId : _playerIds) { packet.writeS(CharNameTable.getInstance().getNameById(playerId)); packet.writeS(""); // memo ? diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java index 8555bb6e86..eb5bfd05d8 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.network.serverpackets; import java.util.List; import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; import org.l2jmobius.commons.network.PacketWriter; @@ -37,7 +38,7 @@ public class ExAcquireSkillInfo implements IClientOutgoingPacket private final int _dualClassLevel; private final long _spCost; private final int _minLevel; - private final List _itemReq; + private final Set _itemReq; private final List _skillRem; /** diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java index 84b5fead76..a163a85735 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java @@ -35,7 +35,7 @@ public class ExChooseShapeShiftingItem implements IClientOutgoingPacket public ExChooseShapeShiftingItem(AppearanceStone stone) { _type = stone.getType(); - _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().get(0); + _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().stream().findFirst().get(); _itemId = stone.getId(); } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/util/DocumentBase.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/util/DocumentBase.java index 28bfbc316c..2ffccdc2ac 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/util/DocumentBase.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/util/DocumentBase.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.util; import java.io.File; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -391,12 +392,12 @@ public abstract class DocumentBase case "races": { final String[] racesVal = a.getNodeValue().split(","); - final Race[] races = new Race[racesVal.length]; + final Set races = EnumSet.noneOf(Race.class); for (int r = 0; r < racesVal.length; r++) { if (racesVal[r] != null) { - races[r] = Race.valueOf(racesVal[r]); + races.add(Race.valueOf(racesVal[r])); } } cond = joinAnd(cond, new ConditionPlayerRace(races)); @@ -673,13 +674,13 @@ public abstract class DocumentBase case "instanceid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final ArrayList array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInstanceId(array)); + cond = joinAnd(cond, new ConditionPlayerInstanceId(set)); break; } case "agathionid": @@ -730,10 +731,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -747,10 +748,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -836,13 +837,13 @@ public abstract class DocumentBase case "insidezoneid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInsideZoneId(array)); + cond = joinAnd(cond, new ConditionPlayerInsideZoneId(set)); break; } case "checkabnormal": @@ -963,13 +964,13 @@ public abstract class DocumentBase case "class_id_restriction": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetClassIdRestriction(array)); + cond = joinAnd(cond, new ConditionTargetClassIdRestriction(set)); break; } case "active_effect_id": @@ -1047,13 +1048,13 @@ public abstract class DocumentBase case "npcid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetNpcId(array)); + cond = joinAnd(cond, new ConditionTargetNpcId(set)); break; } case "npctype": diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/handlers/bypasshandlers/Link.java b/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/handlers/bypasshandlers/Link.java index 5097e77f56..2cb1581627 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/handlers/bypasshandlers/Link.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/handlers/bypasshandlers/Link.java @@ -16,7 +16,9 @@ */ package handlers.bypasshandlers; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.HashSet; +import java.util.Set; + import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.handler.IBypassHandler; import org.l2jmobius.gameserver.model.actor.Creature; @@ -31,28 +33,29 @@ public class Link implements IBypassHandler "Link" }; - private static final String[] VALID_LINKS = + private static final Set VALID_LINKS = new HashSet<>(); + static { - "common/craft_01.htm", - "common/craft_02.htm", - "common/runes_01.htm", - "common/skill_enchant_help_01.htm", - "common/skill_enchant_help_02.htm", - "common/skill_enchant_help_03.htm", - "default/BlessingOfProtection.htm", - "default/SupportMagic.htm", - "fisherman/fishing_manual001.htm", - "fisherman/fishing_manual002.htm", - "fisherman/fishing_manual003.htm", - "fisherman/fishing_manual004.htm", - "fisherman/fishing_manual005.htm", - "fortress/foreman.htm", - "petmanager/evolve.htm", - "petmanager/exchange.htm", - "petmanager/instructions.htm", - "warehouse/clanwh.htm", - "warehouse/privatewh.htm", - }; + VALID_LINKS.add("common/craft_01.htm"); + VALID_LINKS.add("common/craft_02.htm"); + VALID_LINKS.add("common/runes_01.htm"); + VALID_LINKS.add("common/skill_enchant_help_01.htm"); + VALID_LINKS.add("common/skill_enchant_help_02.htm"); + VALID_LINKS.add("common/skill_enchant_help_03.htm"); + VALID_LINKS.add("default/BlessingOfProtection.htm"); + VALID_LINKS.add("default/SupportMagic.htm"); + VALID_LINKS.add("fisherman/fishing_manual001.htm"); + VALID_LINKS.add("fisherman/fishing_manual002.htm"); + VALID_LINKS.add("fisherman/fishing_manual003.htm"); + VALID_LINKS.add("fisherman/fishing_manual004.htm"); + VALID_LINKS.add("fisherman/fishing_manual008.htm"); + VALID_LINKS.add("fortress/foreman.htm"); + VALID_LINKS.add("petmanager/evolve.htm"); + VALID_LINKS.add("petmanager/exchange.htm"); + VALID_LINKS.add("petmanager/instructions.htm"); + VALID_LINKS.add("warehouse/clanwh.htm"); + VALID_LINKS.add("warehouse/privatewh.htm"); + } @Override public boolean useBypass(String command, Player player, Creature target) @@ -70,12 +73,13 @@ public class Link implements IBypassHandler return false; } - String content = CommonUtil.contains(VALID_LINKS, htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; + String content = VALID_LINKS.contains(htmlPath) ? HtmCache.getInstance().getHtm(player, "data/html/" + htmlPath) : null; // Precaution. if (htmlPath.startsWith("teleporter/") && !(player.getTarget() instanceof Teleporter)) { content = null; } + final NpcHtmlMessage html = new NpcHtmlMessage(target != null ? target.getObjectId() : 0); if (content != null) { diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java b/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java index b18ea0d506..171c3003dd 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/handlers/dailymissionhandlers/MonsterDailyMissionHandler.java @@ -16,8 +16,9 @@ */ package handlers.dailymissionhandlers; -import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.Config; import org.l2jmobius.gameserver.enums.DailyMissionStatus; @@ -41,7 +42,7 @@ public class MonsterDailyMissionHandler extends AbstractDailyMissionHandler private final int _amount; private final int _minLevel; private final int _maxLevel; - private final List _ids = new ArrayList<>(); + private final Set _ids = new HashSet<>(); public MonsterDailyMissionHandler(DailyMissionDataHolder holder) { diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/handlers/itemhandlers/PetFood.java b/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/handlers/itemhandlers/PetFood.java index 3c5572d4ec..8b908ea095 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/handlers/itemhandlers/PetFood.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/handlers/itemhandlers/PetFood.java @@ -17,6 +17,7 @@ package handlers.itemhandlers; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.PetDataTable; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -79,7 +80,7 @@ public class PetFood implements IItemHandler final Player player = activeChar.getActingPlayer(); if (player.isMounted()) { - final List foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); + final Set foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood(); if (foodIds.contains(item.getId()) && player.destroyItem("Consume", item.getObjectId(), 1, null, false)) { player.broadcastPacket(new MagicSkillUse(player, player, skillId, skillLevel, 0, 0)); diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java b/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java index 2ad282f683..99f45fbb41 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/handlers/skillconditionhandlers/OpCheckResidenceSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.ClanHallData; import org.l2jmobius.gameserver.model.StatSet; @@ -32,12 +33,12 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpCheckResidenceSkillCondition implements ISkillCondition { - private final List _residencesId; + private final Set _residencesId = new HashSet<>(); private final boolean _isWithin; public OpCheckResidenceSkillCondition(StatSet params) { - _residencesId = params.getList("residencesId", Integer.class); + _residencesId.addAll(params.getList("residencesId", Integer.class)); _isWithin = params.getBoolean("isWithin"); } diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java b/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java index fc2934423b..4a8282d988 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/handlers/skillconditionhandlers/OpNeedSummonOrPetSkillCondition.java @@ -16,9 +16,9 @@ */ package handlers.skillconditionhandlers; -import java.util.ArrayList; -import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -28,18 +28,18 @@ import org.l2jmobius.gameserver.model.skill.ISkillCondition; import org.l2jmobius.gameserver.model.skill.Skill; /** - * @author UnAfraid + * @author UnAfraid, Mobius */ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition { - private final List _npcIds = new ArrayList<>(); + private final Set _npcIds = new HashSet<>(); public OpNeedSummonOrPetSkillCondition(StatSet params) { - final List npcIds = params.getList("npcIds", String.class); + final List npcIds = params.getList("npcIds", Integer.class); if (npcIds != null) { - npcIds.stream().map(Integer::valueOf).forEach(_npcIds::add); + _npcIds.addAll(npcIds); } } @@ -47,7 +47,19 @@ public class OpNeedSummonOrPetSkillCondition implements ISkillCondition public boolean canUse(Creature caster, Skill skill, WorldObject target) { final Summon pet = caster.getPet(); - final Collection summons = caster.getServitors().values(); - return ((pet != null) && _npcIds.stream().anyMatch(npcId -> npcId == pet.getId())) || summons.stream().anyMatch(summon -> _npcIds.contains(summon.getId())); + if ((pet != null) && _npcIds.contains(pet.getId())) + { + return true; + } + + for (Summon summon : caster.getServitors().values()) + { + if (_npcIds.contains(summon.getId())) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java b/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java index 8541bc62b4..ef81b291d4 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetDoorSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,11 +30,11 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetDoorSkillCondition implements ISkillCondition { - private final List _doorIds; + private final Set _doorIds = new HashSet<>(); public OpTargetDoorSkillCondition(StatSet params) { - _doorIds = params.getList("doorIds", Integer.class); + _doorIds.addAll(params.getList("doorIds", Integer.class)); } @Override diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java b/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java index 3ce4145703..0ccd571e19 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetNpcSkillCondition.java @@ -16,7 +16,8 @@ */ package handlers.skillconditionhandlers; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; @@ -29,17 +30,17 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class OpTargetNpcSkillCondition implements ISkillCondition { - private final List _npcId; + private final Set _npcIds = new HashSet<>(); public OpTargetNpcSkillCondition(StatSet params) { - _npcId = params.getList("npcIds", Integer.class); + _npcIds.addAll(params.getList("npcIds", Integer.class)); } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget(); - return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId()); + return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcIds.contains(actualTarget.getId()); } } diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/instances/AbstractInstance.java b/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/instances/AbstractInstance.java index 4b40e5f74c..ac59736fb4 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/instances/AbstractInstance.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/data/scripts/instances/AbstractInstance.java @@ -16,9 +16,10 @@ */ package instances; +import java.util.HashSet; import java.util.List; +import java.util.Set; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.enums.InstanceReenterType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.instancemanager.InstanceManager; @@ -40,25 +41,29 @@ import ai.AbstractNpcAI; */ public abstract class AbstractInstance extends AbstractNpcAI { - private final int[] _templateIds; + private final Set _templateIds = new HashSet<>(); - public AbstractInstance(int... templateId) + public AbstractInstance(int... templateIds) { - if (templateId.length == 0) + if (templateIds.length == 0) { throw new IllegalStateException("No template ids were provided!"); } - _templateIds = templateId; + + for (int templateId : templateIds) + { + _templateIds.add(templateId); + } } - public int[] getTemplateId() + public Set getTemplateId() { return _templateIds; } public boolean isInInstance(Instance instance) { - return (instance != null) && CommonUtil.contains(_templateIds, instance.getTemplateId()); + return (instance != null) && _templateIds.contains(instance.getTemplateId()); } /** diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/Config.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/Config.java index ac9acc3107..0e1caed230 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/Config.java @@ -288,7 +288,7 @@ public class Config public static boolean AUTO_LOOT_SLOT_LIMIT; public static int LOOT_RAIDS_PRIVILEGE_INTERVAL; public static int LOOT_RAIDS_PRIVILEGE_CC_SIZE; - public static List AUTO_LOOT_ITEM_IDS; + public static Set AUTO_LOOT_ITEM_IDS; public static boolean ENABLE_KEYBOARD_MOVEMENT; public static int UNSTUCK_INTERVAL; public static int TELEPORT_WATCHDOG_TIMEOUT; @@ -477,7 +477,7 @@ public class Config public static boolean ALLOW_DISCARDITEM; public static int AUTODESTROY_ITEM_AFTER; public static int HERB_AUTO_DESTROY_TIME; - public static List LIST_PROTECTED_ITEMS; + public static Set LIST_PROTECTED_ITEMS; public static boolean DATABASE_CLEAN_UP; public static int CHAR_DATA_STORE_INTERVAL; public static int CLAN_VARIABLES_STORE_INTERVAL; @@ -568,7 +568,7 @@ public class Config public static boolean ALT_OLY_LOG_FIGHTS; public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS; public static boolean ALT_OLY_ANNOUNCE_GAMES; - public static List LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(); + public static Set LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(); public static int ALT_OLY_WEAPON_ENCHANT_LIMIT; public static int ALT_OLY_ARMOR_ENCHANT_LIMIT; public static int ALT_OLY_WAIT_TIME; @@ -1196,9 +1196,9 @@ public class Config public static int AUTO_CP_PERCENTAGE; public static int AUTO_HP_PERCENTAGE; public static int AUTO_MP_PERCENTAGE; - public static List AUTO_CP_ITEM_IDS; - public static List AUTO_HP_ITEM_IDS; - public static List AUTO_MP_ITEM_IDS; + public static Set AUTO_CP_ITEM_IDS; + public static Set AUTO_HP_ITEM_IDS; + public static Set AUTO_MP_ITEM_IDS; public static boolean CUSTOM_STARTING_LOC; public static int CUSTOM_STARTING_LOC_X; public static int CUSTOM_STARTING_LOC_Y; @@ -1208,7 +1208,7 @@ public class Config public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; public static int MOB_MIN_SPAWN_RANGE; public static int MOB_MAX_SPAWN_RANGE; - public static List MOBS_LIST_NOT_RANDOM; + public static Set MOBS_LIST_NOT_RANDOM; public static boolean FREE_JUMPS_FOR_ALL; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; @@ -1227,7 +1227,7 @@ public class Config public static boolean COMMUNITY_PREMIUM_SYSTEM_ENABLED; public static int COMMUNITY_PREMIUM_COIN_ID; public static int COMMUNITY_PREMIUM_PRICE_PER_DAY; - public static List COMMUNITY_AVAILABLE_BUFFS; + public static Set COMMUNITY_AVAILABLE_BUFFS; public static Map COMMUNITY_AVAILABLE_TELEPORTS; public static boolean CUSTOM_DEPOSITABLE_ENABLED; public static boolean CUSTOM_DEPOSITABLE_QUEST_ITEMS; @@ -1877,7 +1877,7 @@ public class Config LOOT_RAIDS_PRIVILEGE_INTERVAL = characterConfig.getInt("RaidLootRightsInterval", 900) * 1000; LOOT_RAIDS_PRIVILEGE_CC_SIZE = characterConfig.getInt("RaidLootRightsCCSize", 45); final String[] autoLootItemIds = characterConfig.getString("AutoLootItemIds", "0").split(","); - AUTO_LOOT_ITEM_IDS = new ArrayList<>(autoLootItemIds.length); + AUTO_LOOT_ITEM_IDS = new HashSet<>(autoLootItemIds.length); for (String item : autoLootItemIds) { Integer itm = 0; @@ -2046,7 +2046,7 @@ public class Config AUTODESTROY_ITEM_AFTER = generalConfig.getInt("AutoDestroyDroppedItemAfter", 600); HERB_AUTO_DESTROY_TIME = generalConfig.getInt("AutoDestroyHerbTime", 60) * 1000; final String[] split = generalConfig.getString("ListOfProtectedItems", "0").split(","); - LIST_PROTECTED_ITEMS = new ArrayList<>(split.length); + LIST_PROTECTED_ITEMS = new HashSet<>(split.length); for (String id : split) { LIST_PROTECTED_ITEMS.add(Integer.parseInt(id)); @@ -2461,7 +2461,7 @@ public class Config if (!olyRestrictedItems.isEmpty()) { final String[] olyRestrictedItemsSplit = olyRestrictedItems.split(","); - LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>(olyRestrictedItemsSplit.length); + LIST_OLY_RESTRICTED_ITEMS = new HashSet<>(olyRestrictedItemsSplit.length); for (String id : olyRestrictedItemsSplit) { LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id)); @@ -2576,17 +2576,17 @@ public class Config AUTO_CP_PERCENTAGE = autoPotionsConfig.getInt("AutoCpPercentage", 70); AUTO_HP_PERCENTAGE = autoPotionsConfig.getInt("AutoHpPercentage", 70); AUTO_MP_PERCENTAGE = autoPotionsConfig.getInt("AutoMpPercentage", 70); - AUTO_CP_ITEM_IDS = new ArrayList<>(); + AUTO_CP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoCpItemIds", "0").split(",")) { AUTO_CP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_HP_ITEM_IDS = new ArrayList<>(); + AUTO_HP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoHpItemIds", "0").split(",")) { AUTO_HP_ITEM_IDS.add(Integer.parseInt(s)); } - AUTO_MP_ITEM_IDS = new ArrayList<>(); + AUTO_MP_ITEM_IDS = new HashSet<>(); for (String s : autoPotionsConfig.getString("AutoMpItemIds", "0").split(",")) { AUTO_MP_ITEM_IDS.add(Integer.parseInt(s)); @@ -3196,7 +3196,7 @@ public class Config COMMUNITY_PREMIUM_COIN_ID = communityBoardConfig.getInt("CommunityPremiumBuyCoinId", 57); COMMUNITY_PREMIUM_PRICE_PER_DAY = communityBoardConfig.getInt("CommunityPremiumPricePerDay", 1000000); final String[] allowedBuffs = communityBoardConfig.getString("CommunityAvailableBuffs", "").split(","); - COMMUNITY_AVAILABLE_BUFFS = new ArrayList<>(allowedBuffs.length); + COMMUNITY_AVAILABLE_BUFFS = new HashSet<>(allowedBuffs.length); for (String s : allowedBuffs) { COMMUNITY_AVAILABLE_BUFFS.add(Integer.parseInt(s)); @@ -3480,7 +3480,7 @@ public class Config if (ENABLE_RANDOM_MONSTER_SPAWNS) { final String[] mobsIds = randomSpawnsConfig.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); - MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + MOBS_LIST_NOT_RANDOM = new HashSet<>(mobsIds.length); for (String id : mobsIds) { MOBS_LIST_NOT_RANDOM.add(Integer.parseInt(id)); diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java index d6e0183c6f..c3977185b4 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/data/xml/ClanHallData.java @@ -202,8 +202,7 @@ public class ClanHallData implements IXmlReader final Door door = DoorData.getInstance().getDoor(doorId); for (ClanHall ch : _clanHalls.values()) { - final List doors = ch.getDoors(); - if ((doors != null) && doors.contains(door)) + if (ch.getDoors().contains(door)) { return ch; } diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java index 6aa0a1fdde..fb395b9e2d 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/data/xml/FakePlayerData.java @@ -17,10 +17,10 @@ package org.l2jmobius.gameserver.data.xml; import java.io.File; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -42,7 +42,7 @@ public class FakePlayerData implements IXmlReader private final Map _fakePlayerInfos = new HashMap<>(); private final Map _fakePlayerNames = new HashMap<>(); private final Map _fakePlayerIds = new HashMap<>(); - private final List _talkableFakePlayerNames = new ArrayList<>(); + private final Set _talkableFakePlayerNames = new HashSet<>(); protected FakePlayerData() { diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/data/xml/VariationData.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/data/xml/VariationData.java index c29a10baa2..079f5b3077 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/data/xml/VariationData.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/data/xml/VariationData.java @@ -20,8 +20,10 @@ import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Logger; @@ -114,14 +116,11 @@ public class VariationData implements IXmlReader }); // Support for specific item ids. - final List itemIds = new ArrayList<>(); + final Set itemIds = new HashSet<>(); forEach(categoryNode, "item", optionNode -> { final int itemId = parseInteger(optionNode.getAttributes(), "id"); - if (!itemIds.contains(itemId)) - { - itemIds.add(itemId); - } + itemIds.add(itemId); }); forEach(categoryNode, "items", optionNode -> { @@ -129,10 +128,7 @@ public class VariationData implements IXmlReader final int toId = parseInteger(optionNode.getAttributes(), "to"); for (int id = fromId; id <= toId; id++) { - if (!itemIds.contains(id)) - { - itemIds.add(id); - } + itemIds.add(id); } }); diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java index d335b95954..1122d7b9ba 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/instancemanager/SellBuffsManager.java @@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -49,7 +51,7 @@ import org.l2jmobius.gameserver.util.Util; public class SellBuffsManager implements IXmlReader { private static final Logger LOGGER = Logger.getLogger(SellBuffsManager.class.getName()); - private static final List ALLOWED_BUFFS = new ArrayList<>(); + private static final Set ALLOWED_BUFFS = new HashSet<>(); private static final String HTML_FOLDER = "data/html/mods/SellBuffs/"; protected SellBuffsManager() @@ -76,11 +78,7 @@ public class SellBuffsManager implements IXmlReader { final Element elem = (Element) node.item(i); final int skillId = Integer.parseInt(elem.getAttribute("id")); - - if (!ALLOWED_BUFFS.contains(skillId)) - { - ALLOWED_BUFFS.add(skillId); - } + ALLOWED_BUFFS.add(skillId); } } diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java index b10f75ef3d..1e45a21319 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/instancemanager/WalkingManager.java @@ -19,8 +19,10 @@ package org.l2jmobius.gameserver.instancemanager; import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; @@ -67,7 +69,7 @@ public class WalkingManager implements IXmlReader public static final byte REPEAT_TELE_FIRST = 2; public static final byte REPEAT_RANDOM = 3; - private final List _targetedNpcIds = new ArrayList<>(); + private final Set _targetedNpcIds = new HashSet<>(); private final Map _routes = new HashMap<>(); // all available routes private final Map _activeRoutes = new HashMap<>(); // each record represents NPC, moving by predefined route from _routes, and moving progress private final Map _routesToAttach = new HashMap<>(); // each record represents NPC and all available routes for it diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/BlockList.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/BlockList.java index 1af9941ed5..9ac6266e22 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/BlockList.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/BlockList.java @@ -19,9 +19,9 @@ package org.l2jmobius.gameserver.model; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -36,10 +36,11 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; public class BlockList { private static final Logger LOGGER = Logger.getLogger(BlockList.class.getName()); - private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); + + private static final Map> OFFLINE_LIST = new ConcurrentHashMap<>(); private final Player _owner; - private List _blockList; + private Set _blockList; public BlockList(Player owner) { @@ -68,9 +69,9 @@ public class BlockList OFFLINE_LIST.put(_owner.getObjectId(), _blockList); } - private static List loadList(int objId) + private static Set loadList(int objId) { - final List list = new ArrayList<>(); + final Set list = new HashSet<>(); try (Connection con = DatabaseFactory.getConnection(); PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1")) { @@ -158,7 +159,7 @@ public class BlockList _owner.setMessageRefusal(value); } - private List getBlockList() + private Set getBlockList() { return _blockList; } diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/PetData.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/PetData.java index 13c808aac7..05421daeae 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/PetData.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/PetData.java @@ -18,8 +18,10 @@ package org.l2jmobius.gameserver.model; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; import org.l2jmobius.gameserver.enums.EvolveLevel; @@ -41,7 +43,7 @@ public class PetData private int _minLevel = Byte.MAX_VALUE; private int _maxLevel = 0; private boolean _syncLevel = false; - private final List _food = new ArrayList<>(); + private final Set _food = new HashSet<>(); private final int _petType; private final int _index; private final int _type; @@ -157,7 +159,7 @@ public class PetData /** * @return the pet's food list. */ - public List getFood() + public Set getFood() { return _food; } diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/SkillLearn.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/SkillLearn.java index a69d30f105..3d5704b5f2 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/SkillLearn.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/SkillLearn.java @@ -16,9 +16,8 @@ */ package org.l2jmobius.gameserver.model; -import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashSet; -import java.util.List; import java.util.Set; import org.l2jmobius.gameserver.data.xml.SkillData; @@ -40,12 +39,12 @@ public class SkillLearn private final int _getDualClassLevel; private final boolean _autoGet; private final long _levelUpSp; - private final List _requiredItems = new ArrayList<>(); - private final List _races = new ArrayList<>(); - private final List _preReqSkills = new ArrayList<>(); + private final Set _requiredItems = new HashSet<>(1); + private final Set _races = EnumSet.noneOf(Race.class); + private final Set _preReqSkills = new HashSet<>(1); private SocialClass _socialClass; private final boolean _residenceSkill; - private final List _residenceIds = new ArrayList<>(); + private final Set _residenceIds = new HashSet<>(1); private final boolean _learnedByNpc; private final boolean _learnedByFS; private final Set _removeSkills = new HashSet<>(1); @@ -133,9 +132,9 @@ public class SkillLearn } /** - * @return the list with the item holders required to acquire this skill. + * @return the set with the item holders required to acquire this skill. */ - public List getRequiredItems() + public Set getRequiredItems() { return _requiredItems; } @@ -150,9 +149,9 @@ public class SkillLearn } /** - * @return a list with the races that can acquire this skill. + * @return a set with the races that can acquire this skill. */ - public List getRaces() + public Set getRaces() { return _races; } @@ -167,9 +166,9 @@ public class SkillLearn } /** - * @return the list of skill holders required to acquire this skill. + * @return the set of skill holders required to acquire this skill. */ - public List getPreReqSkills() + public Set getPreReqSkills() { return _preReqSkills; } @@ -212,9 +211,9 @@ public class SkillLearn } /** - * @return a list with the Ids where this skill is available. + * @return a set with the Ids where this skill is available. */ - public List getResidenceIds() + public Set getResidenceIds() { return _residenceIds; } diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java index b10ba3f8de..81cf539dd2 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/instance/Pet.java @@ -263,7 +263,7 @@ public class Pet extends Summon broadcastStatusUpdate(); - final List foodIds = getPetData().getFood(); + final Set foodIds = getPetData().getFood(); if (foodIds.isEmpty()) { if (isUncontrollable()) diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java index 1a97730017..08104cb5d1 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/instance/Trap.java @@ -16,8 +16,8 @@ */ package org.l2jmobius.gameserver.model.actor.instance; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import org.l2jmobius.commons.threads.ThreadPool; @@ -57,7 +57,7 @@ public class Trap extends Npc private boolean _isTriggered; private final int _lifeTime; private Player _owner; - private final List _playersWhoDetectedMe = new ArrayList<>(); + private final Set _playersWhoDetectedMe = new HashSet<>(); private final SkillHolder _skill; private int _remainingTime; // Tasks diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java index 71ef076212..3ba8c20a9b 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/tasks/player/PetFeedTask.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor.tasks.player; -import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -69,11 +69,12 @@ public class PetFeedTask implements Runnable _player.sendPacket(SystemMessageId.YOU_ARE_OUT_OF_FEED_MOUNT_STATUS_CANCELED); } - final List foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); + final Set foodIds = _player.getPetData(_player.getMountNpcId()).getFood(); if (foodIds.isEmpty()) { return; } + Item food = null; for (int id : foodIds) { diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java index 50d2a821c3..2611b5f121 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInsideZoneId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.actor.Creature; @@ -29,9 +29,9 @@ import org.l2jmobius.gameserver.model.zone.ZoneType; */ public class ConditionPlayerInsideZoneId extends Condition { - private final List _zones; + private final Set _zones; - public ConditionPlayerInsideZoneId(List zones) + public ConditionPlayerInsideZoneId(Set zones) { _zones = zones; } diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java index c15065eca2..d644f663f5 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerInstanceId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Player; @@ -29,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerInstanceId extends Condition { - private final List _instanceIds; + private final Set _instanceIds; /** * Instantiates a new condition player instance id. * @param instanceIds the instance ids */ - public ConditionPlayerInstanceId(List instanceIds) + public ConditionPlayerInstanceId(Set instanceIds) { _instanceIds = instanceIds; } diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java index 14d61089ed..7c375ec45e 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRace.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -28,13 +29,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionPlayerRace extends Condition { - private final Race[] _races; + private final Set _races; /** * Instantiates a new condition player race. * @param races the list containing the allowed races. */ - public ConditionPlayerRace(Race[] races) + public ConditionPlayerRace(Set races) { _races = races; } @@ -46,6 +47,6 @@ public class ConditionPlayerRace extends Condition { return false; } - return CommonUtil.contains(_races, effector.getActingPlayer().getRace()); + return _races.contains(effector.getActingPlayer().getRace()); } } diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java index 0f54766571..0b326e3f40 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId())) + if (_npcIds.contains(target.getId())) { existNpc = true; break; diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java index c5c9b5ff0e..db64b6bd7b 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerRangeFromSummonedNpc.java @@ -16,7 +16,8 @@ */ package org.l2jmobius.gameserver.model.conditions; -import org.l2jmobius.commons.util.CommonUtil; +import java.util.Set; + import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -30,13 +31,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; public class ConditionPlayerRangeFromSummonedNpc extends Condition { /** NPC Ids. */ - private final int[] _npcIds; + private final Set _npcIds; /** Radius to check. */ private final int _radius; /** Expected value. */ private final boolean _value; - public ConditionPlayerRangeFromSummonedNpc(int[] npcIds, int radius, boolean value) + public ConditionPlayerRangeFromSummonedNpc(Set npcIds, int radius, boolean value) { _npcIds = npcIds; _radius = radius; @@ -47,11 +48,11 @@ public class ConditionPlayerRangeFromSummonedNpc extends Condition public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item) { boolean existNpc = false; - if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0)) + if (!_npcIds.isEmpty() && (_radius > 0)) { for (Npc target : World.getInstance().getVisibleObjectsInRange(effector, Npc.class, _radius)) { - if (CommonUtil.contains(_npcIds, target.getId()) && (effector == target.getSummoner())) + if (_npcIds.contains(target.getId()) && (effector == target.getSummoner())) { existNpc = true; break; diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java index a3fb0f5374..a47b4b4983 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetClassIdRestriction.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetClassIdRestriction extends Condition { - private final List _classIds; + private final Set _classIds; /** * Instantiates a new condition target class id restriction. * @param classId the class id */ - public ConditionTargetClassIdRestriction(List classId) + public ConditionTargetClassIdRestriction(Set classId) { _classIds = classId; } diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java index 82b1bd5877..9bb694f4ef 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/conditions/ConditionTargetNpcId.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.conditions; -import java.util.List; +import java.util.Set; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.item.ItemTemplate; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.model.skill.Skill; */ public class ConditionTargetNpcId extends Condition { - private final List _npcIds; + private final Set _npcIds; /** * Instantiates a new condition target npc id. * @param npcIds the npc ids */ - public ConditionTargetNpcId(List npcIds) + public ConditionTargetNpcId(Set npcIds) { _npcIds = npcIds; } diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java index f26329bc21..5c86f26ae5 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/holders/EventDropHolder.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.model.holders; -import java.util.Collection; +import java.util.Set; /** * @author Mobius @@ -25,9 +25,9 @@ public class EventDropHolder extends DropHolder { private final int _minLevel; private final int _maxLevel; - private final Collection _monsterIds; + private final Set _monsterIds; - public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Collection monsterIds) + public EventDropHolder(int itemId, long min, long max, double chance, int minLevel, int maxLevel, Set monsterIds) { super(null, itemId, min, max, chance); _minLevel = minLevel; @@ -45,7 +45,7 @@ public class EventDropHolder extends DropHolder return _maxLevel; } - public Collection getMonsterIds() + public Set getMonsterIds() { return _monsterIds; } diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java index d74b1218d3..5d694e5169 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/item/appearance/AppearanceStone.java @@ -17,9 +17,10 @@ package org.l2jmobius.gameserver.model.item.appearance; import java.time.Duration; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.enums.Race; @@ -47,12 +48,12 @@ public class AppearanceStone private final ArmorType _armorType; private final AppearanceHandType _handType; private final AppearanceMagicType _magicType; - private List _crystalTypes; - private List _targetTypes; - private List _bodyParts; - private List _races; - private List _racesNot; - private List _allVisualIds; + private Set _crystalTypes; + private Set _targetTypes; + private Set _bodyParts; + private Set _races; + private Set _racesNot; + private Set _allVisualIds; public AppearanceStone(StatSet set) { @@ -172,35 +173,35 @@ public class AppearanceStone { if (_crystalTypes == null) { - _crystalTypes = new ArrayList<>(); + _crystalTypes = EnumSet.noneOf(CrystalType.class); } _crystalTypes.add(type); } - public List getCrystalTypes() + public Set getCrystalTypes() { - return _crystalTypes != null ? _crystalTypes : Collections.emptyList(); + return _crystalTypes != null ? _crystalTypes : Collections.emptySet(); } public void addTargetType(AppearanceTargetType type) { if (_targetTypes == null) { - _targetTypes = new ArrayList<>(); + _targetTypes = EnumSet.noneOf(AppearanceTargetType.class); } _targetTypes.add(type); } - public List getTargetTypes() + public Set getTargetTypes() { - return _targetTypes != null ? _targetTypes : Collections.emptyList(); + return _targetTypes != null ? _targetTypes : Collections.emptySet(); } public void addBodyPart(long part) { if (_bodyParts == null) { - _bodyParts = new ArrayList<>(); + _bodyParts = new HashSet<>(); } _bodyParts.add(part); } @@ -209,47 +210,47 @@ public class AppearanceStone { if (_allVisualIds == null) { - _allVisualIds = new ArrayList<>(); + _allVisualIds = new HashSet<>(); } _allVisualIds.add(appearanceHolder); } - public List getVisualIds() + public Set getVisualIds() { - return _allVisualIds != null ? _allVisualIds : Collections.emptyList(); + return _allVisualIds != null ? _allVisualIds : Collections.emptySet(); } - public List getBodyParts() + public Set getBodyParts() { - return _bodyParts != null ? _bodyParts : Collections.emptyList(); + return _bodyParts != null ? _bodyParts : Collections.emptySet(); } public void addRace(Race race) { if (_races == null) { - _races = new ArrayList<>(); + _races = EnumSet.noneOf(Race.class); } _races.add(race); } - public List getRaces() + public Set getRaces() { - return _races != null ? _races : Collections.emptyList(); + return _races != null ? _races : Collections.emptySet(); } public void addRaceNot(Race race) { if (_racesNot == null) { - _racesNot = new ArrayList<>(); + _racesNot = EnumSet.noneOf(Race.class); } _racesNot.add(race); } - public List getRacesNot() + public Set getRacesNot() { - return _racesNot != null ? _racesNot : Collections.emptyList(); + return _racesNot != null ? _racesNot : Collections.emptySet(); } /** @@ -302,7 +303,7 @@ public class AppearanceStone { // Seems like in retail item with already changed appearance, can be changed again without being restored. - final AppearanceTargetType targetType = getTargetTypes().get(0); + final AppearanceTargetType targetType = getTargetTypes().stream().findFirst().get(); switch (targetType) { case NONE: diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java index e8cb83ad95..007afb2d72 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/item/enchant/AbstractEnchantItem.java @@ -16,16 +16,16 @@ */ package org.l2jmobius.gameserver.model.item.enchant; +import java.util.EnumSet; +import java.util.Set; import java.util.logging.Logger; -import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.item.ItemTemplate; import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.model.item.type.CrystalType; import org.l2jmobius.gameserver.model.item.type.EtcItemType; -import org.l2jmobius.gameserver.model.item.type.ItemType; /** * @author UnAfraid @@ -34,28 +34,29 @@ public abstract class AbstractEnchantItem { protected static final Logger LOGGER = Logger.getLogger(AbstractEnchantItem.class.getName()); - private static final ItemType[] ENCHANT_TYPES = new ItemType[] + private static final Set ENCHANT_TYPES = EnumSet.noneOf(EtcItemType.class); + static { - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM, - EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP, - EtcItemType.BLESS_ENCHT_AM, - EtcItemType.BLESS_ENCHT_AM_DOWN, - EtcItemType.BLESS_ENCHT_WP, - EtcItemType.ENCHT_AM, - EtcItemType.ENCHT_WP, - EtcItemType.GIANT_ENCHT_AM, - EtcItemType.GIANT_ENCHT_WP, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM, - EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP, - EtcItemType.CURSED_ENCHT_AM, - EtcItemType.CURSED_ENCHT_WP, - }; + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_ANCIENT_CRYSTAL_ENCHANT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_AM_DOWN); + ENCHANT_TYPES.add(EtcItemType.BLESS_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.BLESSED_GIANT_ENCHT_ATTR_INC_PROP_ENCHT_WP); + ENCHANT_TYPES.add(EtcItemType.CURSED_ENCHT_AM); + ENCHANT_TYPES.add(EtcItemType.CURSED_ENCHT_WP); + } private final int _id; private final CrystalType _grade; @@ -74,7 +75,7 @@ public abstract class AbstractEnchantItem { throw new NullPointerException(); } - else if (!CommonUtil.contains(ENCHANT_TYPES, getItem().getItemType())) + else if (!ENCHANT_TYPES.contains(getItem().getItemType())) { throw new IllegalAccessError(); } diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/item/henna/Henna.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/item/henna/Henna.java index 307147ae31..824caeabd3 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/item/henna/Henna.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/item/henna/Henna.java @@ -17,9 +17,11 @@ package org.l2jmobius.gameserver.model.item.henna; import java.util.ArrayList; -import java.util.HashMap; +import java.util.EnumMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.actor.Player; @@ -35,14 +37,14 @@ public class Henna private final int _dyeId; private final int _dyeItemId; private final int _patternLevel; - private final Map _baseStats = new HashMap<>(); + private final Map _baseStats = new EnumMap<>(BaseStat.class); private final int _wearFee; private final int _wearCount; private final int _cancelFee; private final int _cancelCount; private final int _duration; private final List _skills; - private final List _wearClass; + private final Set _wearClass; public Henna(StatSet set) { @@ -61,7 +63,7 @@ public class Henna _cancelCount = set.getInt("cancel_count"); _duration = set.getInt("duration", -1); _skills = new ArrayList<>(); - _wearClass = new ArrayList<>(); + _wearClass = new HashSet<>(); } /** @@ -149,7 +151,7 @@ public class Henna /** * @return the list with the allowed classes to wear this dye. */ - public List getAllowedWearClass() + public Set getAllowedWearClass() { return _wearClass; } diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/options/OptionDataCategory.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/options/OptionDataCategory.java index dd8d1e4281..4e7856e4a2 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/options/OptionDataCategory.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/options/OptionDataCategory.java @@ -16,9 +16,9 @@ */ package org.l2jmobius.gameserver.model.options; -import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import org.l2jmobius.commons.util.Rnd; @@ -28,10 +28,10 @@ import org.l2jmobius.commons.util.Rnd; public class OptionDataCategory { private final Map _options; - private final List _itemIds; + private final Set _itemIds; private final double _chance; - public OptionDataCategory(Map options, List itemIds, double chance) + public OptionDataCategory(Map options, Set itemIds, double chance) { _options = options; _itemIds = itemIds; @@ -59,7 +59,7 @@ public class OptionDataCategory return result; } - public List getItemIds() + public Set getItemIds() { return _itemIds; } diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java index 5ba6755084..18508d0145 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/quest/LongTimeEvent.java @@ -24,8 +24,10 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Set; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -184,7 +186,7 @@ public class LongTimeEvent extends Quest final Node maxLevelNode = d.getAttributes().getNamedItem("maxLevel"); final int maxLevel = maxLevelNode == null ? Integer.MAX_VALUE : Integer.parseInt(maxLevelNode.getNodeValue()); final Node monsterIdsNode = d.getAttributes().getNamedItem("monsterIds"); - final List monsterIds = new ArrayList<>(); + final Set monsterIds = new HashSet<>(); if (monsterIdsNode != null) { for (String id : monsterIdsNode.getNodeValue().split(",")) diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/residences/ClanHall.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/residences/ClanHall.java index 57aa313704..2fb931a64c 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/residences/ClanHall.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/residences/ClanHall.java @@ -23,7 +23,9 @@ import java.sql.SQLException; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -61,9 +63,9 @@ public class ClanHall extends AbstractResidence private final int _minBid; final int _lease; private final int _deposit; - private final List _npcs; - private final List _doors; - private final List _teleports; + private final Set _npcs = new HashSet<>(); + private final Set _doors = new HashSet<>(); + private final Set _teleports = new HashSet<>(); private final Location _ownerLocation; private final Location _banishLocation; // Dynamic parameters @@ -85,9 +87,21 @@ public class ClanHall extends AbstractResidence _minBid = params.getInt("minBid"); _lease = params.getInt("lease"); _deposit = params.getInt("deposit"); - _npcs = params.getList("npcList", Integer.class); - _doors = params.getList("doorList", Door.class); - _teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + final List npcs = params.getList("npcList", Integer.class); + if (npcs != null) + { + _npcs.addAll(npcs); + } + final List doors = params.getList("doorList", Door.class); + if (doors != null) + { + _doors.addAll(doors); + } + final List teleports = params.getList("teleportList", ClanHallTeleportHolder.class); + if (teleports != null) + { + _teleports.addAll(teleports); + } _ownerLocation = params.getLocation("owner_loc"); _banishLocation = params.getLocation("banish_loc"); // Set dynamic parameters (from DB) @@ -196,7 +210,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Door} related to this {@link ClanHall}. * @return all {@link Door} related to this {@link ClanHall} */ - public List getDoors() + public Set getDoors() { return _doors; } @@ -205,7 +219,7 @@ public class ClanHall extends AbstractResidence * Gets all {@link Npc} related to this {@link ClanHall}. * @return all {@link Npc} related to this {@link ClanHall} */ - public List getNpcs() + public Set getNpcs() { return _npcs; } @@ -324,7 +338,7 @@ public class ClanHall extends AbstractResidence return _banishLocation; } - public List getTeleportList() + public Set getTeleportList() { return _teleports; } diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/siege/Castle.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/siege/Castle.java index 0244ddbd3b..210c516669 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/siege/Castle.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/siege/Castle.java @@ -21,8 +21,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.Calendar; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -83,7 +85,7 @@ public class Castle extends AbstractResidence private SiegeZone _zone = null; private ResidenceTeleportZone _teleZone; private Clan _formerOwner = null; - private final List _artefacts = new ArrayList<>(1); + private final Set _artefacts = new HashSet<>(1); private final Map _function = new ConcurrentHashMap<>(); private int _ticketBuyCount = 0; private boolean _isFirstMidVictory = false; @@ -1072,7 +1074,7 @@ public class Castle extends AbstractResidence _artefacts.add(artefact); } - public List getArtefacts() + public Set getArtefacts() { return _artefacts; } diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java index 0c79677eae..4ebf954ee5 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/BlockListPacket.java @@ -16,7 +16,7 @@ */ package org.l2jmobius.gameserver.network.serverpackets; -import java.util.List; +import java.util.Set; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.gameserver.data.sql.CharNameTable; @@ -27,19 +27,19 @@ import org.l2jmobius.gameserver.network.OutgoingPackets; */ public class BlockListPacket implements IClientOutgoingPacket { - private final List _playersId; + private final Set _playerIds; - public BlockListPacket(List playersId) + public BlockListPacket(Set playerIds) { - _playersId = playersId; + _playerIds = playerIds; } @Override public boolean write(PacketWriter packet) { OutgoingPackets.BLOCK_LIST.writeId(packet); - packet.writeD(_playersId.size()); - for (int playerId : _playersId) + packet.writeD(_playerIds.size()); + for (int playerId : _playerIds) { packet.writeS(CharNameTable.getInstance().getNameById(playerId)); packet.writeS(""); // memo ? diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java index 8555bb6e86..eb5bfd05d8 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/ExAcquireSkillInfo.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.network.serverpackets; import java.util.List; import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; import org.l2jmobius.commons.network.PacketWriter; @@ -37,7 +38,7 @@ public class ExAcquireSkillInfo implements IClientOutgoingPacket private final int _dualClassLevel; private final long _spCost; private final int _minLevel; - private final List _itemReq; + private final Set _itemReq; private final List _skillRem; /** diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java index 84b5fead76..a163a85735 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/appearance/ExChooseShapeShiftingItem.java @@ -35,7 +35,7 @@ public class ExChooseShapeShiftingItem implements IClientOutgoingPacket public ExChooseShapeShiftingItem(AppearanceStone stone) { _type = stone.getType(); - _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().get(0); + _targetType = stone.getTargetTypes().size() > 1 ? AppearanceTargetType.ALL : stone.getTargetTypes().stream().findFirst().get(); _itemId = stone.getId(); } diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/util/DocumentBase.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/util/DocumentBase.java index 28bfbc316c..2ffccdc2ac 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/util/DocumentBase.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/util/DocumentBase.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.util; import java.io.File; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -391,12 +392,12 @@ public abstract class DocumentBase case "races": { final String[] racesVal = a.getNodeValue().split(","); - final Race[] races = new Race[racesVal.length]; + final Set races = EnumSet.noneOf(Race.class); for (int r = 0; r < racesVal.length; r++) { if (racesVal[r] != null) { - races[r] = Race.valueOf(racesVal[r]); + races.add(Race.valueOf(racesVal[r])); } } cond = joinAnd(cond, new ConditionPlayerRace(races)); @@ -673,13 +674,13 @@ public abstract class DocumentBase case "instanceid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final ArrayList array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInstanceId(array)); + cond = joinAnd(cond, new ConditionPlayerInstanceId(set)); break; } case "agathionid": @@ -730,10 +731,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -747,10 +748,10 @@ public abstract class DocumentBase if (st.countTokens() == 3) { final String[] ids = st.nextToken().split(";"); - final int[] npcIds = new int[ids.length]; + final Set npcIds = new HashSet<>(ids.length); for (int index = 0; index < ids.length; index++) { - npcIds[index] = Integer.parseInt(getValue(ids[index], template)); + npcIds.add(Integer.parseInt(getValue(ids[index], template))); } final int radius = Integer.parseInt(st.nextToken()); final boolean val = Boolean.parseBoolean(st.nextToken()); @@ -836,13 +837,13 @@ public abstract class DocumentBase case "insidezoneid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, template))); + set.add(Integer.decode(getValue(item, template))); } - cond = joinAnd(cond, new ConditionPlayerInsideZoneId(array)); + cond = joinAnd(cond, new ConditionPlayerInsideZoneId(set)); break; } case "checkabnormal": @@ -963,13 +964,13 @@ public abstract class DocumentBase case "class_id_restriction": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetClassIdRestriction(array)); + cond = joinAnd(cond, new ConditionTargetClassIdRestriction(set)); break; } case "active_effect_id": @@ -1047,13 +1048,13 @@ public abstract class DocumentBase case "npcid": { final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ","); - final List array = new ArrayList<>(st.countTokens()); + final Set set = new HashSet<>(st.countTokens()); while (st.hasMoreTokens()) { final String item = st.nextToken().trim(); - array.add(Integer.decode(getValue(item, null))); + set.add(Integer.decode(getValue(item, null))); } - cond = joinAnd(cond, new ConditionTargetNpcId(array)); + cond = joinAnd(cond, new ConditionTargetNpcId(set)); break; } case "npctype":