• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rusocode / ao-server / 17193670034

24 Aug 2025 08:55PM UTC coverage: 57.057% (-2.4%) from 59.47%
17193670034

push

github

rusocode
refactor: migrated from ini4j to apache.commons due to vulnerabilities

- New IniUtils class to read values from ini
- Converted the City.java class to record and now handles map limits
- obj.dat
 # Almost all keys were renamed in English for better consistency.
 # The “magical_weapon” flag was added to differentiate it from the ‘magical_power’ key (formerly called “StaffPower”), so now we have three types
   of weapons: RANGED_WEAPON, MAGICAL_WEAPON, and MELEE_WEAPON
 # Now the blacksmithing skill covers both the manufacture of items that require ingots and the smelting of ore to obtain them. This means
   that the “MinSkill” key, which was used to represent the skill required to smelt ore and also served to represent
   the skill required to use ships (boat, galley, and galleon), has been removed. Now, in order to use ships, the “navigation_skill” skill has been created, and the skill for smelting ore (formerly ‘MinSkill’) is integrated into “smithing_skill.”

580 of 1187 branches covered (48.86%)

Branch coverage included in aggregate %.

2545 of 4290 relevant lines covered (59.32%)

2.98 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.43
server/src/main/java/com/ao/model/worldobject/factory/WorldObjectFactory.java
1
package com.ao.model.worldobject.factory;
2

3
import com.ao.model.worldobject.*;
4
import com.ao.model.worldobject.properties.WorldObjectProperties;
5

6
import java.util.HashMap;
7

8
/**
9
 * Factory to create instances of items based on their properties.
10
 */
11

12
public class WorldObjectFactory {
×
13

14
    protected static final HashMap<WorldObjectType, Class<? extends WorldObject>> worldObjectMapper;
15

16
    static {
17
        worldObjectMapper = new HashMap<>();
4✔
18
        worldObjectMapper.put(WorldObjectType.ACCESSORY, Accessory.class);
5✔
19
        worldObjectMapper.put(WorldObjectType.DEXTERITY_POTION, DexterityPotion.class);
5✔
20
        worldObjectMapper.put(WorldObjectType.AMMUNITION, Ammunition.class);
5✔
21
//                worldObjectMapper.put(WorldObjectType.ANVIL, Anvil.class);
22
        worldObjectMapper.put(WorldObjectType.ARMOR, Armor.class);
5✔
23
        worldObjectMapper.put(WorldObjectType.BACKPACK, Backpack.class);
5✔
24
        worldObjectMapper.put(WorldObjectType.BOAT, Boat.class);
5✔
25
        worldObjectMapper.put(WorldObjectType.DEATH_POTION, DeathPotion.class);
5✔
26
        worldObjectMapper.put(WorldObjectType.DOOR, Door.class);
5✔
27
        worldObjectMapper.put(WorldObjectType.DRINK, Drink.class);
5✔
28
        worldObjectMapper.put(WorldObjectType.EMPTY_BOTTLE, EmptyBottle.class);
5✔
29
        worldObjectMapper.put(WorldObjectType.FILLED_BOTTLE, FilledBottle.class);
5✔
30
        worldObjectMapper.put(WorldObjectType.FOOD, Food.class);
5✔
31
//                worldObjectMapper.put(WorldObjectType.FORGE, Forge.class);
32
        worldObjectMapper.put(WorldObjectType.FORUM, Forum.class);
5✔
33
        worldObjectMapper.put(WorldObjectType.GRABABLE_PROP, GrabableProp.class);
5✔
34
        worldObjectMapper.put(WorldObjectType.HELMET, Helmet.class);
5✔
35
        worldObjectMapper.put(WorldObjectType.HP_POTION, HPPotion.class);
5✔
36
        worldObjectMapper.put(WorldObjectType.INGOT, Ingot.class);
5✔
37
        worldObjectMapper.put(WorldObjectType.KEY, Key.class);
5✔
38
        worldObjectMapper.put(WorldObjectType.MANA_POTION, ManaPotion.class);
5✔
39
        worldObjectMapper.put(WorldObjectType.MINE, Mine.class);
5✔
40
        worldObjectMapper.put(WorldObjectType.MINERAL, Mineral.class);
5✔
41
        worldObjectMapper.put(WorldObjectType.MONEY, Gold.class);
5✔
42
        worldObjectMapper.put(WorldObjectType.MUSICAL_INSTRUMENT, MusicalInstrument.class);
5✔
43
        worldObjectMapper.put(WorldObjectType.PARCHMENT, Parchment.class);
5✔
44
        worldObjectMapper.put(WorldObjectType.POISON_POTION, PoisonPotion.class);
5✔
45
        worldObjectMapper.put(WorldObjectType.PROP, Prop.class);
5✔
46
        worldObjectMapper.put(WorldObjectType.RANGED_WEAPON, RangedWeapon.class);
5✔
47
        worldObjectMapper.put(WorldObjectType.SHIELD, Shield.class);
5✔
48
        worldObjectMapper.put(WorldObjectType.SIGN, Sign.class);
5✔
49
        worldObjectMapper.put(WorldObjectType.MAGICAL_WEAPON, Staff.class);
5✔
50
        worldObjectMapper.put(WorldObjectType.STRENGTH_POTION, StrengthPotion.class);
5✔
51
        worldObjectMapper.put(WorldObjectType.TELEPORT, Teleport.class);
5✔
52
        worldObjectMapper.put(WorldObjectType.TREE, Tree.class);
5✔
53
        worldObjectMapper.put(WorldObjectType.MELEE_WEAPON, Weapon.class);
5✔
54
        worldObjectMapper.put(WorldObjectType.WOOD, Wood.class);
5✔
55
    }
1✔
56

57
    /**
58
     * Creates a new instance of the appropriate AbstractItem given its properties.
59
     *
60
     * @param woProperties properties from which to create an object
61
     * @param amount       amount of the given object to create
62
     * @return the newly created object
63
     */
64
    public AbstractItem getWorldObject(WorldObjectProperties woProperties, int amount) throws WorldObjectFactoryException {
65
        @SuppressWarnings("unchecked")
66
        Class<? extends AbstractItem> woClass = (Class<? extends AbstractItem>) worldObjectMapper.get(woProperties.getType());
×
67
        try {
68
            return woClass.getConstructor(woProperties.getClass(), int.class).newInstance(woProperties, amount);
×
69
        } catch (Exception e) {
×
70
            throw new WorldObjectFactoryException(e);
×
71
        }
72
    }
73

74
    /**
75
     * Creates a new instance of the appropriate WorldObject given its properties.
76
     *
77
     * @param woProperties properties from which to create an object
78
     * @return the newly created object
79
     */
80
    public WorldObject getWorldObject(WorldObjectProperties woProperties) throws WorldObjectFactoryException {
81
        Class<? extends WorldObject> woClass = worldObjectMapper.get(woProperties.getType());
×
82
        try {
83
            return woClass.getConstructor(woProperties.getClass()).newInstance(woProperties);
×
84
        } catch (Exception e) {
×
85
            throw new WorldObjectFactoryException(e);
×
86
        }
87
    }
88

89
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc