Skip to content

Recommendations

Ckblck edited this page Dec 23, 2021 · 2 revisions

You may often find situations where both ArmorPiece#getPreviousPiece() and ArmorPiece#getPiece() both share the same material type.

When this happens, there are two possibilities:

  • ArmorPiece#getMethod() is Method#UNCHANGED

    The armour piece was not modified at all. This could happen f. eg. when a player modified another piece. You may filter it this way:

    for (ArmorPiece armorPiece : event.getArmorPieces()) {
        Method method = armorPiece.getMethod();
                       
        if (method == Method.UNCHANGED)
            continue;
    
        // The armor piece has suffered from a modification.
    }
  • ArmorPiece#getMethod() is Method#DAMAGED

    In this case, the player did not implicitly have his armour modified. Instead, such piece got damaged.

    for (ArmorPiece armorPiece : event.getArmorPieces()) {                        
        if (armorPiece.hasBeenDamaged()) // The same as (armorpiece.getMethod() == Method.DAMAGED)
            continue;
    
        // The armor piece was not damaged.
    }

It is up to the developer to determine how these situations should be handled. The library will always provide the complete array of armour pieces a player is wearing. In most cases, only one armour slot gets modified.

This information is compulsory to be borne in mind, as these situations will occasionally happen.

Clone this wiki locally