Removed bad localization system
This commit is contained in:
@@ -13,7 +13,6 @@ import com.willfp.eco.core.integrations.placeholder.PlaceholderIntegration;
|
||||
import com.willfp.eco.core.proxy.Cleaner;
|
||||
import com.willfp.eco.core.proxy.ProxyFactory;
|
||||
import com.willfp.eco.core.scheduling.Scheduler;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
@@ -135,14 +134,6 @@ public interface Handler {
|
||||
*/
|
||||
Cleaner getCleaner();
|
||||
|
||||
/**
|
||||
* Get a localized string.
|
||||
*
|
||||
* @param key The key.
|
||||
* @return The string.
|
||||
*/
|
||||
String getLocalizedString(@NotNull NamespacedKey key);
|
||||
|
||||
/**
|
||||
* Add new plugin.
|
||||
*
|
||||
|
||||
@@ -5,7 +5,6 @@ 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;
|
||||
@@ -169,7 +168,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(StringUtils.getLocalizedString(plugin.getNamespacedKeyFactory().create("not-player")));
|
||||
sender.sendMessage(plugin.getLangYml().getMessage("not-player"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
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;
|
||||
@@ -59,7 +58,7 @@ public class TestableStack implements TestableItem {
|
||||
List<String> lore = meta.hasLore() ? meta.getLore() : new ArrayList<>();
|
||||
assert lore != null;
|
||||
lore.add("");
|
||||
String add = StringUtils.getLocalizedString(NamespacedKeyUtils.createEcoKey("multiple-in-craft"));
|
||||
String add = Eco.getHandler().getEcoPlugin().getLangYml().getString("multiple-in-craft");
|
||||
add = add.replace("%amount%", String.valueOf(amount));
|
||||
lore.add(add);
|
||||
meta.setLore(lore);
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
package com.willfp.eco.util;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.willfp.eco.core.Eco;
|
||||
import com.willfp.eco.core.integrations.placeholder.PlaceholderManager;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -253,14 +251,4 @@ public class StringUtils {
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a localized string.
|
||||
*
|
||||
* @param key The key.
|
||||
* @return The string.
|
||||
*/
|
||||
public String getLocalizedString(@NotNull final NamespacedKey key) {
|
||||
return Eco.getHandler().getLocalizedString(key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.willfp.eco.internal.i18n;
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EcoLocalizedMessage extends EcoLocalizedString {
|
||||
/**
|
||||
* Create a localized message.
|
||||
*
|
||||
* @param plugin The plugin.
|
||||
* @param id The message id.
|
||||
*/
|
||||
public EcoLocalizedMessage(@NotNull final EcoPlugin plugin,
|
||||
@NotNull final String id) {
|
||||
super(plugin, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getPlugin().getLangYml().getMessage(this.getId());
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.willfp.eco.internal.i18n;
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin;
|
||||
import com.willfp.eco.core.PluginDependent;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EcoLocalizedString extends PluginDependent<EcoPlugin> {
|
||||
/**
|
||||
* The message ID.
|
||||
*/
|
||||
@Getter
|
||||
private final String id;
|
||||
|
||||
/**
|
||||
* Create a localized message.
|
||||
*
|
||||
* @param plugin The plugin.
|
||||
* @param id The message id.
|
||||
*/
|
||||
public EcoLocalizedString(@NotNull final EcoPlugin plugin,
|
||||
@NotNull final String id) {
|
||||
super(plugin);
|
||||
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getPlugin().getLangYml().getString(id);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.willfp.eco.internal.i18n;
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@UtilityClass
|
||||
public class LocalizationUtils {
|
||||
public EcoLocalizedString getStringFromKey(@NotNull final NamespacedKey key) {
|
||||
Validate.isTrue(EcoPlugin.getPluginNames().contains(key.getNamespace()));
|
||||
|
||||
EcoPlugin source = EcoPlugin.getPlugin(key.getNamespace());
|
||||
|
||||
assert source != null;
|
||||
|
||||
String message = source.getLangYml().getStringOrNull("messages." + key.getKey());
|
||||
|
||||
if (message == null) {
|
||||
return new EcoLocalizedString(source, key.getKey());
|
||||
} else {
|
||||
return new EcoLocalizedMessage(source, key.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,12 +26,10 @@ import com.willfp.eco.internal.factory.EcoMetadataValueFactory;
|
||||
import com.willfp.eco.internal.factory.EcoNamespacedKeyFactory;
|
||||
import com.willfp.eco.internal.factory.EcoRunnableFactory;
|
||||
import com.willfp.eco.internal.gui.EcoGUIFactory;
|
||||
import com.willfp.eco.internal.i18n.LocalizationUtils;
|
||||
import com.willfp.eco.internal.integrations.PlaceholderIntegrationPAPI;
|
||||
import com.willfp.eco.internal.logging.EcoLogger;
|
||||
import com.willfp.eco.internal.proxy.EcoProxyFactory;
|
||||
import com.willfp.eco.internal.scheduling.EcoScheduler;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -124,11 +122,6 @@ public final class EcoHandler extends EcoSpigotPlugin implements Handler {
|
||||
return new EcoProxyFactory(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocalizedString(@NotNull final NamespacedKey key) {
|
||||
return LocalizationUtils.getStringFromKey(key).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNewPlugin(@NotNull final EcoPlugin plugin) {
|
||||
Plugins.LOADED_ECO_PLUGINS.put(plugin.getName().toLowerCase(), plugin);
|
||||
|
||||
Reference in New Issue
Block a user