Localization changes

This commit is contained in:
Auxilor
2021-07-15 12:17:02 +02:00
committed by Auxilor
parent 76e808b8b1
commit 083f643ce2
7 changed files with 39 additions and 12 deletions

View File

@@ -5,6 +5,7 @@ import com.willfp.eco.core.PluginDependent;
import com.willfp.eco.core.command.CommandBase;
import com.willfp.eco.core.command.CommandHandler;
import com.willfp.eco.core.command.TabCompleteHandler;
import com.willfp.eco.util.StringUtils;
import lombok.AccessLevel;
import lombok.Getter;
import org.bukkit.command.CommandSender;
@@ -168,7 +169,7 @@ abstract class HandledCommand extends PluginDependent<EcoPlugin> implements Comm
@NotNull final CommandBase command,
@NotNull final EcoPlugin plugin) {
if (command.isPlayersOnly() && !(sender instanceof Player)) {
sender.sendMessage(plugin.getLangYml().getMessage("not-player"));
sender.sendMessage(StringUtils.getLocalizedString(plugin.getNamespacedKeyFactory().create("not-player")));
return false;
}

View File

@@ -1,7 +1,8 @@
package com.willfp.eco.core.recipe.parts;
import com.willfp.eco.core.Eco;
import com.willfp.eco.core.items.TestableItem;
import com.willfp.eco.util.NamespacedKeyUtils;
import com.willfp.eco.util.StringUtils;
import lombok.Getter;
import org.apache.commons.lang.Validate;
import org.bukkit.inventory.ItemStack;
@@ -58,7 +59,7 @@ public class TestableStack implements TestableItem {
List<String> lore = meta.hasLore() ? meta.getLore() : new ArrayList<>();
assert lore != null;
lore.add("");
String add = Eco.getHandler().getEcoPlugin().getLangYml().getString("multiple-in-craft");
String add = StringUtils.getLocalizedString(NamespacedKeyUtils.createEcoKey("multiple-in-craft"));
add = add.replace("%amount%", String.valueOf(amount));
lore.add(add);
meta.setLore(lore);

View File

@@ -0,0 +1,20 @@
package com.willfp.eco.util;
import lombok.experimental.UtilityClass;
import org.bukkit.NamespacedKey;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
@UtilityClass
public class NamespacedKeyUtils {
/**
* Create a NamespacedKey for eco.
*
* @param string The string.
* @return The key.
*/
public NamespacedKey createEcoKey(@NotNull final String string) {
return Objects.requireNonNull(NamespacedKey.fromString("eco:" + string));
}
}