feat(C-01): i18n main commands — 148 translatable keys
Phase 3: Migrate Component.literal() in all remaining command files. - NPCCommand (34), CellCommand (33), SocialCommand (16), CollarCommand (25), KeyCommand (18), BountyCommand (6), KidnapSetCommand (2), CaptivityDebugCommand (7), InventorySubCommand (3), TestAnimSubCommand (2), MasterTestSubCommand (7), DebtSubCommand (8) - Strip all section sign color codes, use .withStyle(ChatFormatting) - 148 new keys in en_us.json (command.tiedup.*) - Debug/dynamic strings intentionally kept as literal
This commit is contained in:
@@ -5,6 +5,7 @@ import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.tiedup.remake.items.ModItems;
|
||||
import java.util.Optional;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
@@ -89,7 +90,7 @@ public class KeyCommand {
|
||||
|
||||
ItemStack key = getHeldKey(player);
|
||||
if (key.isEmpty()) {
|
||||
source.sendFailure(Component.literal("You must hold a collar key"));
|
||||
source.sendFailure(Component.translatable("command.tiedup.key.must_hold_key"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -101,7 +102,7 @@ public class KeyCommand {
|
||||
!tag.getUUID(TAG_OWNER).equals(player.getUUID())
|
||||
) {
|
||||
source.sendFailure(
|
||||
Component.literal("This key is already claimed by someone else")
|
||||
Component.translatable("command.tiedup.key.already_claimed")
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
@@ -110,7 +111,7 @@ public class KeyCommand {
|
||||
tag.putString(TAG_OWNER_NAME, player.getName().getString());
|
||||
|
||||
source.sendSuccess(
|
||||
() -> Component.literal("§aYou have claimed this key"),
|
||||
() -> Component.translatable("command.tiedup.key.claimed").withStyle(ChatFormatting.GREEN),
|
||||
false
|
||||
);
|
||||
|
||||
@@ -129,19 +130,19 @@ public class KeyCommand {
|
||||
|
||||
ItemStack key = getHeldKey(player);
|
||||
if (key.isEmpty()) {
|
||||
source.sendFailure(Component.literal("You must hold a collar key"));
|
||||
source.sendFailure(Component.translatable("command.tiedup.key.must_hold_key"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
CompoundTag tag = key.getOrCreateTag();
|
||||
|
||||
if (!tag.hasUUID(TAG_OWNER)) {
|
||||
source.sendFailure(Component.literal("This key is not claimed"));
|
||||
source.sendFailure(Component.translatable("command.tiedup.key.not_claimed"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!tag.getUUID(TAG_OWNER).equals(player.getUUID())) {
|
||||
source.sendFailure(Component.literal("You do not own this key"));
|
||||
source.sendFailure(Component.translatable("command.tiedup.key.not_owner"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -149,7 +150,7 @@ public class KeyCommand {
|
||||
tag.remove(TAG_OWNER_NAME);
|
||||
|
||||
source.sendSuccess(
|
||||
() -> Component.literal("§aYou have unclaimed this key"),
|
||||
() -> Component.translatable("command.tiedup.key.unclaimed").withStyle(ChatFormatting.GREEN),
|
||||
false
|
||||
);
|
||||
|
||||
@@ -170,7 +171,7 @@ public class KeyCommand {
|
||||
|
||||
ItemStack key = getHeldKey(player);
|
||||
if (key.isEmpty()) {
|
||||
source.sendFailure(Component.literal("You must hold a collar key"));
|
||||
source.sendFailure(Component.translatable("command.tiedup.key.must_hold_key"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -181,7 +182,7 @@ public class KeyCommand {
|
||||
tag.hasUUID(TAG_OWNER) &&
|
||||
!tag.getUUID(TAG_OWNER).equals(player.getUUID())
|
||||
) {
|
||||
source.sendFailure(Component.literal("You do not own this key"));
|
||||
source.sendFailure(Component.translatable("command.tiedup.key.not_owner"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -190,9 +191,9 @@ public class KeyCommand {
|
||||
|
||||
source.sendSuccess(
|
||||
() ->
|
||||
Component.literal(
|
||||
"§aAssigned key to " + target.getName().getString()
|
||||
),
|
||||
Component.translatable(
|
||||
"command.tiedup.key.assigned", target.getName().getString()
|
||||
).withStyle(ChatFormatting.GREEN),
|
||||
false
|
||||
);
|
||||
|
||||
@@ -211,7 +212,7 @@ public class KeyCommand {
|
||||
|
||||
ItemStack key = getHeldKey(player);
|
||||
if (key.isEmpty()) {
|
||||
source.sendFailure(Component.literal("You must hold a collar key"));
|
||||
source.sendFailure(Component.translatable("command.tiedup.key.must_hold_key"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -222,7 +223,7 @@ public class KeyCommand {
|
||||
tag.hasUUID(TAG_OWNER) &&
|
||||
!tag.getUUID(TAG_OWNER).equals(player.getUUID())
|
||||
) {
|
||||
source.sendFailure(Component.literal("You do not own this key"));
|
||||
source.sendFailure(Component.translatable("command.tiedup.key.not_owner"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -231,9 +232,9 @@ public class KeyCommand {
|
||||
|
||||
source.sendSuccess(
|
||||
() ->
|
||||
Component.literal(
|
||||
"§aKey is now " + (isPublic ? "public" : "private")
|
||||
),
|
||||
Component.translatable(
|
||||
isPublic ? "command.tiedup.key.now_public" : "command.tiedup.key.now_private"
|
||||
).withStyle(ChatFormatting.GREEN),
|
||||
false
|
||||
);
|
||||
|
||||
@@ -252,40 +253,40 @@ public class KeyCommand {
|
||||
|
||||
ItemStack key = getHeldKey(player);
|
||||
if (key.isEmpty()) {
|
||||
source.sendFailure(Component.literal("You must hold a collar key"));
|
||||
source.sendFailure(Component.translatable("command.tiedup.key.must_hold_key"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
CompoundTag tag = key.getOrCreateTag();
|
||||
|
||||
source.sendSuccess(
|
||||
() -> Component.literal("§6=== Key Info ==="),
|
||||
() -> Component.translatable("command.tiedup.key.info_header").withStyle(ChatFormatting.GOLD),
|
||||
false
|
||||
);
|
||||
|
||||
String ownerName = tag.getString(TAG_OWNER_NAME);
|
||||
source.sendSuccess(
|
||||
() ->
|
||||
Component.literal(
|
||||
"§7Owner: §f" +
|
||||
(ownerName.isEmpty() ? "Not claimed" : ownerName)
|
||||
),
|
||||
Component.translatable(
|
||||
"command.tiedup.key.info_owner",
|
||||
ownerName.isEmpty() ? "Not claimed" : ownerName
|
||||
).withStyle(ChatFormatting.GRAY),
|
||||
false
|
||||
);
|
||||
|
||||
String targetName = tag.getString(TAG_TARGET_NAME);
|
||||
source.sendSuccess(
|
||||
() ->
|
||||
Component.literal(
|
||||
"§7Assigned to: §f" +
|
||||
(targetName.isEmpty() ? "Not assigned" : targetName)
|
||||
),
|
||||
Component.translatable(
|
||||
"command.tiedup.key.info_assigned",
|
||||
targetName.isEmpty() ? "Not assigned" : targetName
|
||||
).withStyle(ChatFormatting.GRAY),
|
||||
false
|
||||
);
|
||||
|
||||
boolean isPublic = tag.getBoolean(TAG_PUBLIC);
|
||||
source.sendSuccess(
|
||||
() -> Component.literal("§7Public: §f" + (isPublic ? "Yes" : "No")),
|
||||
() -> Component.translatable("command.tiedup.key.info_public", isPublic ? "Yes" : "No").withStyle(ChatFormatting.GRAY),
|
||||
false
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user