diff --git a/src/main/java/com/cleanroommc/modularui/widget/Widget.java b/src/main/java/com/cleanroommc/modularui/widget/Widget.java index 71e11fdac..3392c6b54 100644 --- a/src/main/java/com/cleanroommc/modularui/widget/Widget.java +++ b/src/main/java/com/cleanroommc/modularui/widget/Widget.java @@ -104,14 +104,14 @@ public void afterInit() {} public void initialiseSyncHandler(ModularSyncManager syncManager) { if (this.syncKey != null) { this.syncHandler = syncManager.getSyncHandler(getPanel().getName(), this.syncKey); - if (!isValidSyncHandler(this.syncHandler)) { - String type = this.syncHandler == null ? null : this.syncHandler.getClass().getName(); - this.syncHandler = null; - throw new IllegalStateException("SyncHandler of type " + type + " is not valid for " + getClass().getName() + ", with key " + this.syncKey); - } - if (this.syncHandler instanceof ValueSyncHandler valueSyncHandler && valueSyncHandler.getChangeListener() == null) { - valueSyncHandler.setChangeListener(this::markTooltipDirty); - } + } + if ((this.syncKey != null || this.syncHandler != null) && !isValidSyncHandler(this.syncHandler)) { + String type = this.syncHandler == null ? null : this.syncHandler.getClass().getName(); + this.syncHandler = null; + throw new IllegalStateException("SyncHandler of type " + type + " is not valid for " + getClass().getName() + ", with key " + this.syncKey); + } + if (this.syncHandler instanceof ValueSyncHandler valueSyncHandler && valueSyncHandler.getChangeListener() == null) { + valueSyncHandler.setChangeListener(this::markTooltipDirty); } }