Skip to content

Recommendations

Ckblck edited this page Dec 17, 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.
    }

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

Clone this wiki locally