@Override
    public Difference<Node> clear() {
        Difference<Node> result = new Difference<>();

        this.lock.lock();
        try {
            // log removals
            for (SortedSet<Node> nodes : this.map.values()) {
                result.recordChanges(ChangeType.REMOVE, nodes);
            }

            // replace the map - this means any client reading async won't be affected
            // by any race conditions between this call to clear and any subsequent call to setContent
            this.map = createMap();
            this.inheritanceMap = createMap();
        } finally {
            this.lock.unlock();
        }

        return result;
    }
This lock is used whilst performing mutations, but *not* reads.

The maps themselves are thread safe, so for querying, we just allow
the read methods to do whatever they want without any locking.
However, we want mutations to be atomic, so we use the lock to ensure that happens.
common/src/main/java/me/lucko/luckperms/common/model/nodemap/NodeMapMutable.java