From f47ad829995de8f9bbc5a6b8570fe0cdb5c71a5f Mon Sep 17 00:00:00 2001 From: Sollace Date: Sun, 27 Jan 2019 20:07:34 +0200 Subject: [PATCH] Added translation keys for the /racelist command --- .../unicopia/command/CommandRacelist.java | 32 ++++++++++++++++--- .../unicopia/command/CommandSpecies.java | 4 +-- .../resources/assets/unicopia/lang/en_US.lang | 11 +++++++ 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/command/CommandRacelist.java b/src/main/java/com/minelittlepony/unicopia/command/CommandRacelist.java index fcb55a50..f6269ba7 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/CommandRacelist.java +++ b/src/main/java/com/minelittlepony/unicopia/command/CommandRacelist.java @@ -13,7 +13,9 @@ import net.minecraft.command.WrongUsageException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.server.MinecraftServer; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentTranslation; +import net.minecraft.util.text.TextFormatting; class CommandRacelist extends CommandBase { @@ -39,17 +41,37 @@ class CommandRacelist extends CommandBase { Race race = Race.fromName(args[1], Race.HUMAN); TextComponentTranslation formattedName = new TextComponentTranslation(race.name().toLowerCase()); + formattedName.getStyle().setColor(TextFormatting.GOLD); - if (race == Race.HUMAN) { + if (race.isDefault()) { player.sendMessage(new TextComponentTranslation("commands.racelist.illegal", formattedName)); } else if (args[0].contentEquals("allow")) { - PlayerSpeciesList.instance().whiteListRace(race); + String translationKey = "commands.racelist.allowed"; + + if (!PlayerSpeciesList.instance().whiteListRace(race)) { + translationKey += ".failed"; + } + + if (sender == player) { + ITextComponent comp = new TextComponentTranslation(translationKey, formattedName); + comp.getStyle().setColor(TextFormatting.GREEN); + player.sendMessage(comp); + } + notifyCommandListener(sender, this, 1, translationKey + ".other", player.getName(), formattedName); - player.sendMessage(new TextComponentTranslation("commands.racelist.allowed", formattedName)); } else if (args[0].contentEquals("disallow")) { - PlayerSpeciesList.instance().unwhiteListRace(race); + String translationKey = "commands.racelist.disallowed"; - player.sendMessage(new TextComponentTranslation("commands.racelist.disallowed", formattedName)); + if (!PlayerSpeciesList.instance().unwhiteListRace(race)) { + translationKey += ".failed"; + } + + if (sender == player) { + ITextComponent comp = new TextComponentTranslation(translationKey, formattedName); + comp.getStyle().setColor(TextFormatting.GREEN); + player.sendMessage(comp); + } + notifyCommandListener(sender, this, 1, translationKey + ".other", player.getName(), formattedName); } else { throw new WrongUsageException(getUsage(sender)); } diff --git a/src/main/java/com/minelittlepony/unicopia/command/CommandSpecies.java b/src/main/java/com/minelittlepony/unicopia/command/CommandSpecies.java index d6c9ee65..68ac3d66 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/CommandSpecies.java +++ b/src/main/java/com/minelittlepony/unicopia/command/CommandSpecies.java @@ -73,10 +73,10 @@ class CommandSpecies extends CommandBase { TextComponentTranslation formattedName = new TextComponentTranslation(species.name().toLowerCase()); if (player != sender) { - notifyCommandListener(sender, this, 1, "commands.race.success.other", player.getName(), formattedName); + notifyCommandListener(sender, this, 1, "commands.race.success.other", formattedName, player.getName()); } else { player.sendMessage(new TextComponentTranslation("commands.race.success.self")); - notifyCommandListener(sender, this, 1, "commands.race.success.otherself", player.getName(), formattedName); + notifyCommandListener(sender, this, 1, "commands.race.success.otherself", formattedName, player.getName()); } } else { player.sendMessage(new TextComponentTranslation("commands.race.permission")); diff --git a/src/main/resources/assets/unicopia/lang/en_US.lang b/src/main/resources/assets/unicopia/lang/en_US.lang index 09336272..ed0e66d4 100644 --- a/src/main/resources/assets/unicopia/lang/en_US.lang +++ b/src/main/resources/assets/unicopia/lang/en_US.lang @@ -121,6 +121,17 @@ commands.race.describe.changeling.1=Beware the changeling, for they can appear w commands.race.describe.changeling.2=Changelings can fly but but do not interact with clouds. commands.race.describe.changeling.3=They have to feed on mobs and other players to eat. +commands.racelist.usage=/racelist +commands.racelist.illegal=The default race %s cannot be used with this command. +commands.racelist.allowed=Added %1$s to the whitelist. +commands.racelist.allowed.failed=%1$s is already whitelisted. +commands.race.success.other=%1$s was added to the whitelist by %2$s. +commands.racelist.allowed.failed.other=%2$s tried to whitelist %1$s but it was already whitelisted. +commands.racelist.disallowed=Removed %1$s from the whitelist. +commands.racelist.disallowed.failed=%1$s is not on the whitelist. +commands.racelist.disallowed.other=%1$s was removed from the whitelist by %2$s. +commands.racelist.disallowed.failed.other=%2$s tried to remove %1$s from the whitelist but it has not been added yet. + commands.decloud.success=%s clouds removed commands.decloud.usage=/decloud