QuiltMC/enigma

redo name proposal

Closed this issue · 0 comments

ix0rai commented

new features:

  • make name proposal based on events -- plugins will have the chance to propose names on jar load, mapping load, and when an entry is renamed
  • add priority based on the order plugins are declared in json
  • track who proposed each name for debugging purposes

draft of the new interface (will likely need another method to help with establishing authorship) :

public interface NameProposalService extends EnigmaService {
    EnigmaServiceType<NameProposalService> TYPE = EnigmaServiceType.create("name_proposal");

    /**
     * Runs when a new JAR file is opened.
     *
     * @param remapper a remapper to use as context for name proposal
     * @return a map of obfuscated entries to their proposed names
     */
    Map<Entry<?>, String> getProposedNames(EntryRemapper remapper);

    /**
     * Runs when an entry is renamed, for updating proposed names that use other mappings as context.
     * Is also run when new mappings are opened -- in that case, {@code obfEntry}, {@code oldMapping}, and {@code newMapping} will be null.
     *
     * @param remapper a remapper to use as context for name proposal
     * @param obfEntry the obfuscated entry that was renamed
     * @param oldMapping the old mapping
     * @param newMapping the new mapping
     * @return a map of obfuscated entries to their proposed names
     */
    Map<Entry<?>, String> updateProposedNames(EntryRemapper remapper, @Nullable Entry<?> obfEntry, EntryMapping oldMapping, EntryMapping newMapping);
}