diff --git a/cardinal-ui/src/main/java/folk/sisby/switchy/client/CardinalClientModuleLoader.java b/cardinal-ui/src/main/java/folk/sisby/switchy/client/CardinalClientModuleLoader.java index 1f77271..cb6904c 100644 --- a/cardinal-ui/src/main/java/folk/sisby/switchy/client/CardinalClientModuleLoader.java +++ b/cardinal-ui/src/main/java/folk/sisby/switchy/client/CardinalClientModuleLoader.java @@ -9,6 +9,7 @@ import com.mojang.serialization.JsonOps; import folk.sisby.switchy.client.api.module.SwitchyClientModuleRegistry; import folk.sisby.switchy.client.api.modules.CardinalSerializerClientModule; +import folk.sisby.switchy.util.Feedback; import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener; import net.minecraft.command.argument.NbtPathArgumentType; import net.minecraft.item.ItemStack; @@ -45,7 +46,7 @@ public class CardinalClientModuleLoader extends JsonDataLoader implements Identi * The global instance for this resource loader. */ public static final CardinalClientModuleLoader INSTANCE = new CardinalClientModuleLoader(new Gson()); - private static final Identifier ID = new Identifier(SwitchyCardinalClient.ID, "module_loader"); + private static final Identifier ID = Feedback.identifier(SwitchyCardinalClient.ID, "module_loader"); private static final String KEY_CONDITION = "condition"; private static final String KEY_ICON = "icon"; private static final String KEY_ICON_PATH = "path"; diff --git a/cardinal/src/main/java/folk/sisby/switchy/CardinalModuleLoader.java b/cardinal/src/main/java/folk/sisby/switchy/CardinalModuleLoader.java index 81b44d8..89028dc 100644 --- a/cardinal/src/main/java/folk/sisby/switchy/CardinalModuleLoader.java +++ b/cardinal/src/main/java/folk/sisby/switchy/CardinalModuleLoader.java @@ -44,7 +44,7 @@ public class CardinalModuleLoader extends JsonDataLoader implements Identifiable * The global instance for this resource loader. */ public static final CardinalModuleLoader INSTANCE = new CardinalModuleLoader(new Gson()); - private static final Identifier ID = new Identifier(SwitchyCardinal.ID, "module_loader"); + private static final Identifier ID = Feedback.identifier(SwitchyCardinal.ID, "module_loader"); private static final String KEY_DEFAULT = "default"; private static final String KEY_EDITABLE = "editable"; private static final String KEY_IF_MODS_LOADED = "ifModsLoaded"; diff --git a/client/src/main/java/folk/sisby/switchy/SwitchyClientServerNetworking.java b/client/src/main/java/folk/sisby/switchy/SwitchyClientServerNetworking.java index 7c2d130..c7a5f05 100644 --- a/client/src/main/java/folk/sisby/switchy/SwitchyClientServerNetworking.java +++ b/client/src/main/java/folk/sisby/switchy/SwitchyClientServerNetworking.java @@ -8,6 +8,7 @@ import folk.sisby.switchy.api.module.SwitchyModuleEditable; import folk.sisby.switchy.api.presets.SwitchyPresets; import folk.sisby.switchy.presets.SwitchyPresetsImpl; +import folk.sisby.switchy.util.Feedback; import folk.sisby.switchy.util.PresetConverter; import folk.sisby.switchy.util.SwitchyCommand; import net.fabricmc.fabric.api.networking.v1.PacketByteBufs; @@ -44,62 +45,62 @@ public class SwitchyClientServerNetworking { /** * Request serialized presets for exporting. */ - public static final Identifier C2S_REQUEST_PRESETS = new Identifier(Switchy.ID, "c2s_presets"); + public static final Identifier C2S_REQUEST_PRESETS = Feedback.identifier(Switchy.ID, "c2s_presets"); /** * Request client-compatible serialized presets for client addon use. */ - public static final Identifier C2S_REQUEST_CLIENT_PRESETS = new Identifier(Switchy.ID, "c2s_client_presets"); + public static final Identifier C2S_REQUEST_CLIENT_PRESETS = Feedback.identifier(Switchy.ID, "c2s_client_presets"); // Actions /** * Send serialized presets to import. * Must be sent twice to finalize - outputs confirmation text in chat. */ - public static final Identifier C2S_IMPORT_CONFIRM = new Identifier(Switchy.ID, "c2s_import_confirm"); + public static final Identifier C2S_IMPORT_CONFIRM = Feedback.identifier(Switchy.ID, "c2s_import_confirm"); /** * Send serialized presets to import. */ - public static final Identifier C2S_IMPORT = new Identifier(Switchy.ID, "c2s_import"); + public static final Identifier C2S_IMPORT = Feedback.identifier(Switchy.ID, "c2s_import"); /** * Send switch action with preset name. */ - public static final Identifier C2S_SWITCH = new Identifier(Switchy.ID, "c2s_switch"); + public static final Identifier C2S_SWITCH = Feedback.identifier(Switchy.ID, "c2s_switch"); /** * Send new preset action with preset name. */ - public static final Identifier C2S_PRESETS_NEW = new Identifier(Switchy.ID, "c2s_presets_new"); + public static final Identifier C2S_PRESETS_NEW = Feedback.identifier(Switchy.ID, "c2s_presets_new"); /** * Send delete preset action with preset name. */ - public static final Identifier C2S_PRESETS_DELETE = new Identifier(Switchy.ID, "c2s_presets_delete"); + public static final Identifier C2S_PRESETS_DELETE = Feedback.identifier(Switchy.ID, "c2s_presets_delete"); /** * Send rename preset action with preset name and new name. */ - public static final Identifier C2S_PRESETS_RENAME = new Identifier(Switchy.ID, "c2s_presets_rename"); + public static final Identifier C2S_PRESETS_RENAME = Feedback.identifier(Switchy.ID, "c2s_presets_rename"); /** * Send disable module action with module ID. */ - public static final Identifier C2S_PRESETS_MODULE_DISABLE = new Identifier(Switchy.ID, "c2s_presets_module_disable"); + public static final Identifier C2S_PRESETS_MODULE_DISABLE = Feedback.identifier(Switchy.ID, "c2s_presets_module_disable"); /** * Send enable module action with module ID. */ - public static final Identifier C2S_PRESETS_MODULE_ENABLE = new Identifier(Switchy.ID, "c2s_presets_module_enable"); + public static final Identifier C2S_PRESETS_MODULE_ENABLE = Feedback.identifier(Switchy.ID, "c2s_presets_module_enable"); // Responses /** * Serialized presets for exporting. */ - public static final Identifier S2C_PRESETS = new Identifier(Switchy.ID, "s2c_presets"); + public static final Identifier S2C_PRESETS = Feedback.identifier(Switchy.ID, "s2c_presets"); /** * Client-compatible serialized presets for previewing. */ - public static final Identifier S2C_CLIENT_PRESETS = new Identifier(Switchy.ID, "s2c_client_presets"); + public static final Identifier S2C_CLIENT_PRESETS = Feedback.identifier(Switchy.ID, "s2c_client_presets"); // Events /** * @see SwitchyEvents.Switch */ - public static final Identifier S2C_EVENT_SWITCH = new Identifier(Switchy.ID, "s2c_event_switch"); + public static final Identifier S2C_EVENT_SWITCH = Feedback.identifier(Switchy.ID, "s2c_event_switch"); // NBT Keys /** diff --git a/client/src/main/java/folk/sisby/switchy/client/argument/IdentifiersArgumentType.java b/client/src/main/java/folk/sisby/switchy/client/argument/IdentifiersArgumentType.java index b65926d..817bc6e 100644 --- a/client/src/main/java/folk/sisby/switchy/client/argument/IdentifiersArgumentType.java +++ b/client/src/main/java/folk/sisby/switchy/client/argument/IdentifiersArgumentType.java @@ -7,6 +7,7 @@ import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; +import folk.sisby.switchy.util.Feedback; import net.minecraft.util.Identifier; import java.util.ArrayList; @@ -76,7 +77,7 @@ public List parse(StringReader reader) throws CommandSyntaxException while (reader.canRead() && isPathCharacterValid(reader.peek())) { reader.skip(); } - outList.add(new Identifier(reader.getString().substring(start, reader.getCursor()))); + outList.add(Feedback.identifier(reader.getString().substring(start, reader.getCursor()))); if (reader.canRead() && reader.peek() == ',') { reader.skip(); if (!reader.canRead() || reader.peek() == ' ') { diff --git a/compat-ui/src/main/java/folk/sisby/switchy/client/modules/OriginsClientModule.java b/compat-ui/src/main/java/folk/sisby/switchy/client/modules/OriginsClientModule.java index e60ef42..6ac4a76 100644 --- a/compat-ui/src/main/java/folk/sisby/switchy/client/modules/OriginsClientModule.java +++ b/compat-ui/src/main/java/folk/sisby/switchy/client/modules/OriginsClientModule.java @@ -47,7 +47,7 @@ public class OriginsClientModule implements SwitchyClientModule, SwitchyUIModule * Identifier for this module. * Must match {@link OriginsModule}. */ - public static final Identifier ID = new Identifier("switchy", "origins"); + public static final Identifier ID = Feedback.identifier("switchy", "origins"); /** * The NBT key where the list of origins is stored. diff --git a/compat-ui/src/main/java/folk/sisby/switchy/client/modules/StyledNicknamesClientModule.java b/compat-ui/src/main/java/folk/sisby/switchy/client/modules/StyledNicknamesClientModule.java index 4f1097b..600ffb9 100644 --- a/compat-ui/src/main/java/folk/sisby/switchy/client/modules/StyledNicknamesClientModule.java +++ b/compat-ui/src/main/java/folk/sisby/switchy/client/modules/StyledNicknamesClientModule.java @@ -6,6 +6,7 @@ import folk.sisby.switchy.modules.StyledNicknamesModule; import folk.sisby.switchy.ui.api.SwitchyUIPosition; import folk.sisby.switchy.ui.api.module.SwitchyUIModule; +import folk.sisby.switchy.util.Feedback; import io.wispforest.owo.ui.component.Components; import io.wispforest.owo.ui.core.Component; import net.minecraft.nbt.NbtCompound; @@ -26,7 +27,7 @@ public class StyledNicknamesClientModule implements SwitchyClientModule, Switchy * Identifier for this module. * Must match {@link StyledNicknamesModule}. */ - public static final Identifier ID = new Identifier("switchy", "styled_nicknames"); + public static final Identifier ID = Feedback.identifier("switchy", "styled_nicknames"); /** * The NBT key where the nickname (in serialized text format) is stored. * Must match {@link StyledNicknamesModule#toClientNbt()}. diff --git a/compat/src/main/java/folk/sisby/switchy/modules/ApoliModule.java b/compat/src/main/java/folk/sisby/switchy/modules/ApoliModule.java index a020d14..83bab3b 100644 --- a/compat/src/main/java/folk/sisby/switchy/modules/ApoliModule.java +++ b/compat/src/main/java/folk/sisby/switchy/modules/ApoliModule.java @@ -7,6 +7,7 @@ import folk.sisby.switchy.api.module.SwitchyModuleInfo; import folk.sisby.switchy.api.module.SwitchyModuleRegistry; import folk.sisby.switchy.config.ApoliModuleConfig; +import folk.sisby.switchy.util.Feedback; import io.github.apace100.apoli.component.PowerHolderComponent; import io.github.apace100.apoli.power.InventoryPower; import io.github.apace100.apoli.power.Power; @@ -40,7 +41,7 @@ public class ApoliModule implements SwitchyModule { /** * Identifier for this module. */ - public static final Identifier ID = new Identifier("switchy", "apoli"); + public static final Identifier ID = Feedback.identifier("switchy", "apoli"); /** * The config object for the apoli module, containing the current state of {@code /config/switchy/apoli.toml}. */ @@ -53,7 +54,7 @@ public class ApoliModule implements SwitchyModule { * The NBT key where the list of power data is stored. */ public static final String KEY_POWER_DATA_LIST = "PowerData"; - private static final Identifier COMMAND_SOURCE = new Identifier("apoli", "command"); + private static final Identifier COMMAND_SOURCE = Feedback.identifier("apoli", "command"); /** * The NBT data for each power. */ diff --git a/compat/src/main/java/folk/sisby/switchy/modules/DrogtorModuleData.java b/compat/src/main/java/folk/sisby/switchy/modules/DrogtorModuleData.java index 569fa1a..1e7d3cc 100644 --- a/compat/src/main/java/folk/sisby/switchy/modules/DrogtorModuleData.java +++ b/compat/src/main/java/folk/sisby/switchy/modules/DrogtorModuleData.java @@ -22,7 +22,7 @@ public class DrogtorModuleData implements SwitchySerializable { /** * Identifier for this module. */ - public static final Identifier ID = new Identifier("switchy", "drogtor"); + public static final Identifier ID = Feedback.identifier("switchy", "drogtor"); /** * The NBT key where the nickname is stored. diff --git a/compat/src/main/java/folk/sisby/switchy/modules/FabricTailorModuleData.java b/compat/src/main/java/folk/sisby/switchy/modules/FabricTailorModuleData.java index db8a7a0..14808c6 100644 --- a/compat/src/main/java/folk/sisby/switchy/modules/FabricTailorModuleData.java +++ b/compat/src/main/java/folk/sisby/switchy/modules/FabricTailorModuleData.java @@ -1,6 +1,7 @@ package folk.sisby.switchy.modules; import folk.sisby.switchy.api.SwitchySerializable; +import folk.sisby.switchy.util.Feedback; import net.minecraft.nbt.NbtCompound; import net.minecraft.util.Identifier; import org.jetbrains.annotations.Nullable; @@ -17,7 +18,7 @@ public class FabricTailorModuleData implements SwitchySerializable { /** * Identifier for this module. */ - public static final Identifier ID = new Identifier("switchy", "fabric_tailor"); + public static final Identifier ID = Feedback.identifier("switchy", "fabric_tailor"); /** * The NBT key where the base64 encoded json skin value is stored. diff --git a/compat/src/main/java/folk/sisby/switchy/modules/FabricationArmorModule.java b/compat/src/main/java/folk/sisby/switchy/modules/FabricationArmorModule.java index 5d3a714..852098e 100644 --- a/compat/src/main/java/folk/sisby/switchy/modules/FabricationArmorModule.java +++ b/compat/src/main/java/folk/sisby/switchy/modules/FabricationArmorModule.java @@ -9,6 +9,7 @@ import folk.sisby.switchy.api.module.SwitchyModuleEditable; import folk.sisby.switchy.api.module.SwitchyModuleInfo; import folk.sisby.switchy.api.module.SwitchyModuleRegistry; +import folk.sisby.switchy.util.Feedback; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.entity.EquipmentSlot; import net.minecraft.item.ItemStack; @@ -42,7 +43,7 @@ public class FabricationArmorModule implements SwitchyModule { /** * Identifier for this module. */ - public static final Identifier ID = new Identifier("switchy", "hidearmor"); + public static final Identifier ID = Feedback.identifier("switchy", "hidearmor"); /** * The NBT key where the list of EquipmentSlots to hide is stored. diff --git a/compat/src/main/java/folk/sisby/switchy/modules/OriginsModule.java b/compat/src/main/java/folk/sisby/switchy/modules/OriginsModule.java index bf77780..151ee61 100644 --- a/compat/src/main/java/folk/sisby/switchy/modules/OriginsModule.java +++ b/compat/src/main/java/folk/sisby/switchy/modules/OriginsModule.java @@ -6,6 +6,7 @@ import folk.sisby.switchy.api.module.SwitchyModuleInfo; import folk.sisby.switchy.api.module.SwitchyModuleRegistry; import folk.sisby.switchy.api.module.SwitchyModuleTransferable; +import folk.sisby.switchy.util.Feedback; import io.github.apace100.origins.component.OriginComponent; import io.github.apace100.origins.origin.Origin; import io.github.apace100.origins.origin.OriginLayer; @@ -35,7 +36,7 @@ public class OriginsModule implements SwitchyModule, SwitchyModuleTransferable { /** * Identifier for this module. */ - public static final Identifier ID = new Identifier("switchy", "origins"); + public static final Identifier ID = Feedback.identifier("switchy", "origins"); /** * The NBT key where the list of origins is stored. diff --git a/compat/src/main/java/folk/sisby/switchy/modules/PehkuiModule.java b/compat/src/main/java/folk/sisby/switchy/modules/PehkuiModule.java index 257b659..a32cedd 100644 --- a/compat/src/main/java/folk/sisby/switchy/modules/PehkuiModule.java +++ b/compat/src/main/java/folk/sisby/switchy/modules/PehkuiModule.java @@ -6,6 +6,7 @@ import folk.sisby.switchy.api.module.SwitchyModuleInfo; import folk.sisby.switchy.api.module.SwitchyModuleRegistry; import folk.sisby.switchy.config.PehkuiModuleConfig; +import folk.sisby.switchy.util.Feedback; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.nbt.NbtCompound; import net.minecraft.server.network.ServerPlayerEntity; @@ -30,7 +31,7 @@ public class PehkuiModule implements SwitchyModule { /** * Identifier for this module. */ - public static final Identifier ID = new Identifier("switchy", "pehkui"); + public static final Identifier ID = Feedback.identifier("switchy", "pehkui"); /** * The config object for the pehkui module, containing the current state of {@code /config/switchy/pehkui.toml}. */ @@ -41,7 +42,7 @@ public class PehkuiModule implements SwitchyModule { public final Map scaleValues = new HashMap<>(); PehkuiModule() { - CONFIG.scaleTypes.forEach(id -> scaleValues.put(ScaleRegistries.SCALE_TYPES.get(new Identifier(id)), null)); + CONFIG.scaleTypes.forEach(id -> scaleValues.put(ScaleRegistries.SCALE_TYPES.get(Feedback.identifier(id)), null)); } /** diff --git a/compat/src/main/java/folk/sisby/switchy/modules/StyledNicknamesModule.java b/compat/src/main/java/folk/sisby/switchy/modules/StyledNicknamesModule.java index f4dd12b..e02e03b 100644 --- a/compat/src/main/java/folk/sisby/switchy/modules/StyledNicknamesModule.java +++ b/compat/src/main/java/folk/sisby/switchy/modules/StyledNicknamesModule.java @@ -10,6 +10,7 @@ import folk.sisby.switchy.api.module.SwitchyModuleInfo; import folk.sisby.switchy.api.module.SwitchyModuleRegistry; import folk.sisby.switchy.api.module.SwitchyModuleTransferable; +import folk.sisby.switchy.util.Feedback; import net.minecraft.nbt.NbtCompound; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; @@ -32,7 +33,7 @@ public class StyledNicknamesModule implements SwitchyModule, SwitchyModuleTransf /** * Identifier for this module. */ - public static final Identifier ID = new Identifier("switchy", "styled_nicknames"); + public static final Identifier ID = Feedback.identifier("switchy", "styled_nicknames"); /** * The NBT key where the nickname is stored. diff --git a/core/src/main/java/folk/sisby/switchy/presets/SwitchyPresetsDataImpl.java b/core/src/main/java/folk/sisby/switchy/presets/SwitchyPresetsDataImpl.java index a1e0718..060fd53 100644 --- a/core/src/main/java/folk/sisby/switchy/presets/SwitchyPresetsDataImpl.java +++ b/core/src/main/java/folk/sisby/switchy/presets/SwitchyPresetsDataImpl.java @@ -7,6 +7,7 @@ import folk.sisby.switchy.api.exception.PresetNotFoundException; import folk.sisby.switchy.api.presets.SwitchyPresetData; import folk.sisby.switchy.api.presets.SwitchyPresetsData; +import folk.sisby.switchy.util.Feedback; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtElement; import net.minecraft.nbt.NbtList; @@ -90,7 +91,7 @@ public void fillFromNbt(NbtCompound nbt) { NbtCompound configCompound = nbt.getCompound(KEY_MODULE_CONFIGS); for (String key : configCompound.getKeys()) { try { - SwitchySerializable config = setConfig(new Identifier(key)); + SwitchySerializable config = setConfig(Feedback.identifier(key)); if (config != null) { config.fillFromNbt(configCompound.getCompound(key)); } diff --git a/core/src/main/java/folk/sisby/switchy/util/Feedback.java b/core/src/main/java/folk/sisby/switchy/util/Feedback.java index 10fa7fa..7f76d85 100644 --- a/core/src/main/java/folk/sisby/switchy/util/Feedback.java +++ b/core/src/main/java/folk/sisby/switchy/util/Feedback.java @@ -61,6 +61,14 @@ public static void sendMessage(ServerPlayerEntity player, Text text) { player.sendMessage(literal("[Switchy] ").setStyle(Style.EMPTY.withColor(Formatting.AQUA)).append(text), false); } + public static Identifier identifier(String identifier) { + return new Identifier(identifier); + } + + public static Identifier identifier(String namespace, String key) { + return new Identifier(namespace, key); + } + /** * Creates translatable text from a key. * diff --git a/gradle.properties b/gradle.properties index 23378f6..02f6b8d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -39,7 +39,7 @@ compatUiId=switchy-compat-ui compatUiName=Switchy Compat UI compatUiDescription=UI previews for Switchy Compat modules for Switchy UI # Mod Version -baseVersion=2.9.4 +baseVersion=2.9.5 # Branch Metadata branch=1.19 tagBranch=1.19 diff --git a/ui/src/main/java/folk/sisby/switchy/ui/screen/ManageScreen.java b/ui/src/main/java/folk/sisby/switchy/ui/screen/ManageScreen.java index 2526beb..ab19aec 100644 --- a/ui/src/main/java/folk/sisby/switchy/ui/screen/ManageScreen.java +++ b/ui/src/main/java/folk/sisby/switchy/ui/screen/ManageScreen.java @@ -311,9 +311,9 @@ public void refresh() { leftModulesFlow.clearChildren(); rightModulesFlow.clearChildren(); int labelSize = 100; - leftModulesFlow.child(getModuleFlow(new Identifier("placeholder", "placeholder"), Feedback.literal(""), (b, i) -> { + leftModulesFlow.child(getModuleFlow(Feedback.identifier("placeholder", "placeholder"), Feedback.literal(""), (b, i) -> { }, true, Feedback.translatable("screen.switchy.manage.modules.disable"), Feedback.literal(""), labelSize).verticalSizing(Sizing.fixed(0))); - rightModulesFlow.child(getModuleFlow(new Identifier("placeholder", "placeholder"), Feedback.literal(""), (b, i) -> { + rightModulesFlow.child(getModuleFlow(Feedback.identifier("placeholder", "placeholder"), Feedback.literal(""), (b, i) -> { }, true, Feedback.translatable("screen.switchy.manage.modules.disable"), Feedback.literal(""), labelSize).verticalSizing(Sizing.fixed(0))); // Disabled Modules @@ -496,9 +496,9 @@ protected void refreshDataModulesFlow() { moduleSelector.leftModulesFlow.clearChildren(); moduleSelector.rightModulesFlow.clearChildren(); int labelSize = 100; - moduleSelector.leftModulesFlow.child(ModuleSelectorFlow.getModuleFlow(new Identifier("placeholder", "placeholder"), Feedback.literal(""), (b, i) -> { + moduleSelector.leftModulesFlow.child(ModuleSelectorFlow.getModuleFlow(Feedback.identifier("placeholder", "placeholder"), Feedback.literal(""), (b, i) -> { }, false, Feedback.translatable("screen.switchy.manage.data.add"), Feedback.literal(""), labelSize).verticalSizing(Sizing.fixed(0))); - moduleSelector.rightModulesFlow.child(ModuleSelectorFlow.getModuleFlow(new Identifier("placeholder", "placeholder"), Feedback.literal(""), (b, i) -> { + moduleSelector.rightModulesFlow.child(ModuleSelectorFlow.getModuleFlow(Feedback.identifier("placeholder", "placeholder"), Feedback.literal(""), (b, i) -> { }, false, Feedback.translatable("screen.switchy.manage.data.remove"), Feedback.literal(""), labelSize).verticalSizing(Sizing.fixed(0))); if (isImporting) {