Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrating to yamlang and rework some text #158

Merged
merged 1 commit into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/main/java/com/plusls/MasaGadget/SharedConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import top.hendrixshen.magiclib.api.compat.minecraft.resources.ResourceLocationCompat;
import top.hendrixshen.magiclib.api.i18n.I18n;
import top.hendrixshen.magiclib.api.malilib.config.MagicConfigManager;
import top.hendrixshen.magiclib.impl.malilib.config.GlobalConfigManager;
import top.hendrixshen.magiclib.impl.malilib.config.MagicConfigHandler;
Expand Down Expand Up @@ -37,4 +38,12 @@ public class SharedConstants {
public static @NotNull ResourceLocation id(String path) {
return ResourceLocationCompat.fromNamespaceAndPath(SharedConstants.modIdentifier, path);
}

public static String tr(String key) {
return I18n.tr(SharedConstants.modIdentifier.concat(".").concat(key));
}

public static String tr(String key, Object... objects) {
return I18n.tr(SharedConstants.modIdentifier.concat(".").concat(key), objects);
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/plusls/MasaGadget/game/ConfigGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public ConfigGui() {
super(
SharedConstants.getModIdentifier(),
SharedConstants.getConfigManager(),
I18n.tr("masa_gadget_mod.gui.title.configs", SharedConstants.getModVersion())
I18n.tr("masa_gadget_mod.gui.title", SharedConstants.getModVersion())
);
}

Expand Down
138 changes: 69 additions & 69 deletions src/main/java/com/plusls/MasaGadget/game/Configs.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,46 +60,9 @@ public class Configs {
@Config(category = ConfigCategory.GENERIC)
public static MagicConfigBooleanHotkeyed renderZombieVillagerConvertTime = Configs.cf.newConfigBooleanHotkeyed("renderZombieVillagerConvertTime", false);

@Dependencies(require = @Dependency(ModId.minihud))
@Config(category = ConfigCategory.GENERIC)
public static MagicConfigHotkey searchMobSpawnPoint = Configs.cf.newConfigHotkey("searchMobSpawnPoint");

@Dependencies(require = @Dependency(ModId.minihud))
@Config(category = ConfigCategory.GENERIC)
public static MagicConfigStringList searchMobSpawnPointBlackList = Configs.cf.newConfigStringList("searchMobSpawnPointBlackList", ImmutableList.of());

@Config(category = ConfigCategory.GENERIC)
public static MagicConfigHotkey syncAllEntityData = Configs.cf.newConfigHotkey("syncAllEntityData");

// Litematica
@Dependencies(require = @Dependency(ModId.litematica))
@Config(category = ConfigCategory.LITEMATICA)
public static MagicConfigBooleanHotkeyed betterEasyPlaceMode = Configs.cf.newConfigBooleanHotkeyed("betterEasyPlaceMode", false);

@Dependencies(require = @Dependency(ModId.litematica))
@Config(category = ConfigCategory.LITEMATICA)
public static MagicConfigBooleanHotkeyed disableLitematicaEasyPlaceFailTip = Configs.cf.newConfigBooleanHotkeyed("disableLitematicaEasyPlaceFailTip", false);

@Dependencies(require = @Dependency(ModId.litematica))
@Config(category = ConfigCategory.LITEMATICA)
public static MagicConfigBooleanHotkeyed fixAccurateProtocol = Configs.cf.newConfigBooleanHotkeyed("fixAccurateProtocol", false);

@Dependencies(require = {
@Dependency(value = ModId.litematica, versionPredicates = "<0.0.0-dev.20210917.192300"),
@Dependency(ModId.tweakeroo),
@Dependency(dependencyType = DependencyType.PLATFORM, platformType = PlatformType.FABRIC_LIKE)
})
@Config(category = ConfigCategory.LITEMATICA)
public static MagicConfigBoolean nudgeSelectionSupportFreeCamera = Configs.cf.newConfigBoolean("nudgeSelectionSupportFreeCamera", false);

@Dependencies(require = @Dependency(ModId.litematica))
@Config(category = ConfigCategory.LITEMATICA)
public static MagicConfigBoolean saveInventoryToSchematicInServer = Configs.cf.newConfigBoolean("saveInventoryToSchematicInServer", false);

@Dependencies(require = @Dependency(ModId.litematica))
@Config(category = ConfigCategory.LITEMATICA)
public static MagicConfigBoolean useRelativePath = Configs.cf.newConfigBoolean("useRelativePath", false);

// MALILIB
@Dependencies(
require = {
Expand Down Expand Up @@ -212,38 +175,6 @@ public class Configs {
@Config(category = ConfigCategory.MALILIB)
public static MagicConfigDouble showOriginalConfigNameScale = Configs.cf.newConfigDouble("showOriginalConfigNameScale", 0.65, 0, 2);

// MiniHUD
@Dependencies(
require = {
@Dependency(value = ModId.minihud, versionPredicates = "<0.31.999-sakura.21"),
@Dependency(dependencyType = DependencyType.PLATFORM, platformType = PlatformType.FABRIC_LIKE)
}
)
@Dependencies(
require = {
@Dependency(value = ModId.minecraft, versionPredicates = "<1.21.1-"),
@Dependency(value = ModId.minihud, versionPredicates = "*"),
@Dependency(dependencyType = DependencyType.PLATFORM, platformType = PlatformType.FORGE_LIKE)
}
)
@Dependencies(
require = {
@Dependency(value = ModId.minecraft, versionPredicates = ">1.21.1-"),
@Dependency(value = ModId.minihud, versionPredicates = ">0.1.21-mc1.21"),
@Dependency(dependencyType = DependencyType.PLATFORM, platformType = PlatformType.FORGE_LIKE)
}
)
@Config(category = ConfigCategory.MINIHUD)
public static MagicConfigBoolean minihudI18n = Configs.cf.newConfigBoolean("minihudI18n", false);

@Dependencies(require = {
@Dependency(ModId.minihud),
@Dependency(ModId.tweakeroo),
@Dependency(value = ModId.minecraft, versionPredicates = ">1.14.4")
})
@Config(category = ConfigCategory.MINIHUD)
public static MagicConfigBoolean pcaSyncProtocolSyncBeehive = Configs.cf.newConfigBoolean("pcaSyncProtocolSyncBeehive", false);

// Tweakeroo
@Dependencies(require = @Dependency(ModId.tweakeroo))
@Config(category = ConfigCategory.TWEAKEROO)
Expand Down Expand Up @@ -294,6 +225,75 @@ public class Configs {
@Config(category = ConfigCategory.TWEAKEROO)
public static MagicConfigStringList restockWithCraftingRecipes = Configs.cf.newConfigStringList("restockWithCraftingRecipes", ImmutableList.of());

// Litematica
@Dependencies(require = @Dependency(ModId.litematica))
@Config(category = ConfigCategory.LITEMATICA)
public static MagicConfigBooleanHotkeyed betterEasyPlaceMode = Configs.cf.newConfigBooleanHotkeyed("betterEasyPlaceMode", false);

@Dependencies(require = @Dependency(ModId.litematica))
@Config(category = ConfigCategory.LITEMATICA)
public static MagicConfigBooleanHotkeyed disableLitematicaEasyPlaceFailTip = Configs.cf.newConfigBooleanHotkeyed("disableLitematicaEasyPlaceFailTip", false);

@Dependencies(require = @Dependency(ModId.litematica))
@Config(category = ConfigCategory.LITEMATICA)
public static MagicConfigBooleanHotkeyed fixAccurateProtocol = Configs.cf.newConfigBooleanHotkeyed("fixAccurateProtocol", false);

@Dependencies(require = {
@Dependency(value = ModId.litematica, versionPredicates = "<0.0.0-dev.20210917.192300"),
@Dependency(ModId.tweakeroo),
@Dependency(dependencyType = DependencyType.PLATFORM, platformType = PlatformType.FABRIC_LIKE)
})
@Config(category = ConfigCategory.LITEMATICA)
public static MagicConfigBoolean nudgeSelectionSupportFreeCamera = Configs.cf.newConfigBoolean("nudgeSelectionSupportFreeCamera", false);

@Dependencies(require = @Dependency(ModId.litematica))
@Config(category = ConfigCategory.LITEMATICA)
public static MagicConfigBoolean saveInventoryToSchematicInServer = Configs.cf.newConfigBoolean("saveInventoryToSchematicInServer", false);

@Dependencies(require = @Dependency(ModId.litematica))
@Config(category = ConfigCategory.LITEMATICA)
public static MagicConfigBoolean useRelativePath = Configs.cf.newConfigBoolean("useRelativePath", false);

// MiniHUD
@Dependencies(
require = {
@Dependency(value = ModId.minihud, versionPredicates = "<0.31.999-sakura.21"),
@Dependency(dependencyType = DependencyType.PLATFORM, platformType = PlatformType.FABRIC_LIKE)
}
)
@Dependencies(
require = {
@Dependency(value = ModId.minecraft, versionPredicates = "<1.21.1-"),
@Dependency(value = ModId.minihud, versionPredicates = "*"),
@Dependency(dependencyType = DependencyType.PLATFORM, platformType = PlatformType.FORGE_LIKE)
}
)
@Dependencies(
require = {
@Dependency(value = ModId.minecraft, versionPredicates = ">1.21.1-"),
@Dependency(value = ModId.minihud, versionPredicates = ">0.1.21-mc1.21"),
@Dependency(dependencyType = DependencyType.PLATFORM, platformType = PlatformType.FORGE_LIKE)
}
)
@Config(category = ConfigCategory.MINIHUD)
public static MagicConfigBoolean minihudI18n = Configs.cf.newConfigBoolean("minihudI18n", false);

@Dependencies(require = {
@Dependency(ModId.minihud),
@Dependency(ModId.tweakeroo),
@Dependency(value = ModId.minecraft, versionPredicates = ">1.14.4")
})
@Config(category = ConfigCategory.MINIHUD)
public static MagicConfigBoolean pcaSyncProtocolSyncBeehive = Configs.cf.newConfigBoolean("pcaSyncProtocolSyncBeehive", false);

@Dependencies(require = @Dependency(ModId.minihud))
@Config(category = ConfigCategory.MINIHUD)
public static MagicConfigHotkey searchMobSpawnPoint = Configs.cf.newConfigHotkey("searchMobSpawnPoint");

@Dependencies(require = @Dependency(ModId.minihud))
@Config(category = ConfigCategory.MINIHUD)
public static MagicConfigStringList searchMobSpawnPointBlackList = Configs.cf.newConfigStringList("searchMobSpawnPointBlackList", ImmutableList.of());

public static void init() {
Configs.cm.parseConfigClass(Configs.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private static void syncInventory(boolean inMemoryOnly, CallbackInfoReturnable<B
@Inject(method = "saveSchematic", at = @At("RETURN"))
private static void postSaveSchematic(boolean inMemoryOnly, CallbackInfoReturnable<Boolean> cir) {
if (Configs.saveInventoryToSchematicInServer.getBooleanValue() && PcaSyncUtil.lastUpdatePos == null) {
InfoUtils.showGuiOrInGameMessage(Message.MessageType.SUCCESS, SharedConstants.getModIdentifier() + ".message.loadInventoryToLocalSuccess");
InfoUtils.showGuiOrInGameMessage(Message.MessageType.SUCCESS, SharedConstants.tr("message.load_inventory_to_local_success"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ protected MixinGuiConfigBase(int listX, int listY) {
});
SharedConstants.getConfigHandler().save();
},
status -> status ? I18n.tr("masa_gadget_mod.message.showAllOptions") :
I18n.tr("masa_gadget_mod.message.showFavorite"));
status -> status ? SharedConstants.tr("gui.button.favorite.show_all") :
SharedConstants.tr("gui.button.favorite.show_favorite_only"));
this.addWidget(favoritesButton);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private void addFavoritesButton(int x, int y, float zLevel, int labelWidth, int

SharedConstants.getConfigHandler().save();
},
status -> status ? I18n.tr("masa_gadget_mod.message.cancelFavorite") :
I18n.tr("masa_gadget_mod.message.setFavorite")));
status -> status ? SharedConstants.tr("gui.button.favorite.cancel") :
SharedConstants.tr("gui.button.favorite.set")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public static void updateBlockEntityHandler(
BlockEntity blockEntity = level.getBlockEntity(pos);

if (Configs.saveInventoryToSchematicInServer.getBooleanValue() && pos.equals(PcaSyncUtil.lastUpdatePos)) {
InfoUtils.showGuiOrInGameMessage(Message.MessageType.SUCCESS, SharedConstants.getModIdentifier() + ".message.loadInventoryToLocalSuccess");
InfoUtils.showGuiOrInGameMessage(Message.MessageType.SUCCESS, SharedConstants.tr("message.loadInventoryToLocalSuccess"));
PcaSyncUtil.lastUpdatePos = null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ private static ShapeDespawnSphere getShapeDespawnSphere() {
if (ret == null) {
ret = (ShapeDespawnSphere) shapeBase;
} else {
InfoUtil.displayChatMessage(ComponentUtil.trCompat("masa_gadget_mod.message.onlySupportOneDespawnShape")
InfoUtil.displayChatMessage(ComponentUtil.trCompat("masa_gadget_mod.message.only_support_one_despawn_shape")
.withStyle(ChatFormatting.RED));
return null;
}
}
}

if (ret == null) {
InfoUtil.displayChatMessage(ComponentUtil.trCompat("masa_gadget_mod.message.canNotFindDespawnShape")
InfoUtil.displayChatMessage(ComponentUtil.trCompat("masa_gadget_mod.message.can_not_find_respawn_shape")
.withStyle(ChatFormatting.RED));
}

Expand Down Expand Up @@ -159,11 +159,11 @@ public static void search() {
MutableComponentCompat text;

if (spawnPos == null) {
text = ComponentUtil.trCompat("masa_gadget_mod.message.noBlockCanSpawn")
text = ComponentUtil.trCompat("masa_gadget_mod.message.no_block_can_spawn")
.withStyle(ChatFormatting.GREEN);
} else {
// for ommc parser
text = ComponentUtil.trCompat("masa_gadget_mod.message.spawnPos", spawnPos.getX(), spawnPos.getY(), spawnPos.getZ());
text = ComponentUtil.trCompat("masa_gadget_mod.message.spawn_pos", spawnPos.getX(), spawnPos.getY(), spawnPos.getZ());

if (MagicLib.getInstance().getCurrentPlatform().isModLoaded(ModId.oh_my_minecraft_client)) {
InfoUtil.sendCommand(String.format("highlightWaypoint %d %d %d", spawnPos.getX(), spawnPos.getY(), spawnPos.getZ()));
Expand Down
Loading