/*
 * This file is part of Sponge, licensed under the MIT License (MIT).
 *
 * Copyright (c) SpongePowered <https://www.spongepowered.org>
 * Copyright (c) contributors
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package org.spongepowered.common.registry.type;

import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.collect.ImmutableList;
import org.spongepowered.api.data.type.NotePitch;
import org.spongepowered.api.data.type.NotePitches;
import org.spongepowered.api.registry.CatalogRegistryModule;
import org.spongepowered.api.registry.util.RegisterCatalog;
import org.spongepowered.common.data.type.SpongeNotePitch;
import org.spongepowered.common.registry.RegistryHelper;

import java.util.Collection;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;

public final class NotePitchRegistryModule implements CatalogRegistryModule<NotePitch> {

    @RegisterCatalog(NotePitches.class)
    private final Map<String, NotePitch> notePitchMap = new HashMap<>();

    @Override
    public Optional<NotePitch> getById(String id) {
        return Optional.ofNullable(this.notePitchMap.get(checkNotNull(id).toLowerCase(Locale.ENGLISH)));
    }

    @Override
    public Collection<NotePitch> getAll() {
        return ImmutableList.copyOf(this.notePitchMap.values());
    }

    @Override
    public void registerDefaults() {
        RegistryHelper.mapFields(NotePitches.class, input -> {
            NotePitch pitch = new SpongeNotePitch((byte) this.notePitchMap.size(), input);
            this.notePitchMap.put(input.toLowerCase(Locale.ENGLISH), pitch);
            return pitch;
        });
    }
}

@@ -1668,28 +1668,34 @@
 ata.
-type.SpongeNotePitch
+processor.common.NoteUtils
 ;%0Aim
@@ -1728,31 +1728,33 @@
 mon.
-registry.RegistryHelper
+data.type.SpongeNotePitch
 ;%0A%0Ai
@@ -2457,153 +2457,72 @@
     
-RegistryHelper.mapFields(NotePitches.class, input -%3E %7B%0A            NotePitch pitch = new SpongeNotePitch((byte) this.notePitchMap.size(), input);
+for (SpongeNotePitch pitch : NoteUtils.pitchMappings.values()) %7B
 %0A   
@@ -2530,21 +2530,16 @@
         
-this.
 notePitc
@@ -2551,13 +2551,21 @@
 put(
-input
+pitch.getId()
 .toL
@@ -2610,37 +2610,9 @@
     
-    return pitch;%0A        %7D);
+%7D
 %0A   

Fix NotePitch objects using the wrong values.