Skip to content

Commit

Permalink
add show version in /carpet command
Browse files Browse the repository at this point in the history
  • Loading branch information
Eyre-S committed Jul 8, 2024
1 parent edbf81b commit d61e58b
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package cc.sukazyo.nukos.carpet.mixin;

import carpet.CarpetServer;
import carpet.api.settings.SettingsManager;
import carpet.utils.Messenger;
import carpet.utils.Translations;
import cc.sukazyo.nukos.carpet.ModCarpetNukos;
import net.minecraft.server.command.ServerCommandSource;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Slice;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(SettingsManager.class)
public class MixinCarpetSettingsManager {

@Inject(
method = "listAllSettings",
slice = @Slice(
from = @At(
value = "CONSTANT",
args = "stringValue=ui.version",
ordinal = 0
)
),
at = @At(
value = "INVOKE",
target = "Lcarpet/api/settings/SettingsManager;getCategories()Ljava/lang/Iterable;",
ordinal = 0
)
)
public void inject_listAlLSettings (ServerCommandSource source, CallbackInfoReturnable<Integer> cir) {
SettingsManager self = (SettingsManager)(Object)this;
if (self != CarpetServer.settingsManager) return;
source.sendFeedback(() -> Messenger.c(
"g %s ".formatted(ModCarpetNukos.NAME),
"g %s: ".formatted(Translations.tr("nukos.versioning")),
"g %s".formatted(ModCarpetNukos.VERSION)
), false);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{

"nukos.versioning": "version",

"carpet.category.nukos": "nukos",

"carpet.rule.anvilItemCostRollupAlgorithm.name": "anvilItemUseCostRollupAlgorithm",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{

"nukos.versioning": "版本",

"carpet.category.nukos": "nukos",

"carpet.rule.anvilItemCostRollupAlgorithm.name": "物品的铁砧累加惩罚算法",
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/carpet_nukos_addition.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"compatibilityLevel": "JAVA_21",
"mixins": [
"MixinAnvilBlock",
"MixinAnvilScreenHandler"
"MixinAnvilScreenHandler",
"MixinCarpetSettingsManager"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit d61e58b

Please sign in to comment.