kami-blue / client

ARCHIVED - KAMI Blue: a continuation of 1.12.2 KAMI
https://kamiblue.org
GNU Lesser General Public License v3.0
361 stars 385 forks source link

bug: CollectionSettings do not trigger a value listener #2200

Open 5HT2 opened 3 years ago

5HT2 commented 3 years ago

Code example:

        visibleList.listeners.add {
            MessageSendHelper.sendRawChatMessage(visibleList.value.toString())
            mc.renderGlobal.loadRenderers()
        }     

This code is never triggered when calling visibleList.add(), or something similar.

You also cannot do visibleList.value = someNewList due to value being a val.

5HT2 commented 3 years ago

Here (https://github.com/kami-blue/client/blob/1dd4db30f390d3d8b0d2359878e6d7597167ba94/src/main/kotlin/org/kamiblue/client/setting/settings/MutableSetting.kt#L36) is the gremlin responsible. It assumes you're always setting the value by doing setting.value = something, which clearly isn't the case for a Collection

5HT2 commented 3 years ago

Theoretically the valueListeners should also work for this as well, when this is fixed

5HT2 commented 3 years ago

A temporary workaround has been added to CollectionSetting by #2186, I don't know of a better way of doing it