Miscellaneous changes

This commit is contained in:
Auxilor
2021-07-15 12:07:47 +02:00
committed by Auxilor
parent 0e02e8f6db
commit 028c7c76da
9 changed files with 186 additions and 8 deletions

View File

@@ -37,11 +37,6 @@ import java.util.logging.Logger;
import java.util.stream.Collectors;
public abstract class EcoPlugin extends JavaPlugin {
/**
* Loaded eco plugins.
*/
public static final List<String> LOADED_ECO_PLUGINS = new ArrayList<>();
/**
* The spigot resource ID of the plugin.
*/
@@ -301,7 +296,7 @@ public abstract class EcoPlugin extends JavaPlugin {
this.langYml = new LangYml(this);
this.configYml = new ConfigYml(this);
LOADED_ECO_PLUGINS.add(this.getName().toLowerCase());
Eco.getHandler().addNewPlugin(this);
}
/**
@@ -665,4 +660,23 @@ public abstract class EcoPlugin extends JavaPlugin {
super.reloadConfig();
}
/**
* Get an EcoPlugin by name.
*
* @param pluginName The name.
* @return The plugin.
*/
public static EcoPlugin getPlugin(@NotNull final String pluginName) {
return Eco.getHandler().getPluginByName(pluginName);
}
/**
* Get all EcoPlugin names.
*
* @return The set of names.
*/
public static Set<String> getPluginNames() {
return new HashSet<>(Eco.getHandler().getLoadedPlugins());
}
}

View File

@@ -13,8 +13,10 @@ 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;
import java.util.logging.Logger;
public interface Handler {
@@ -132,4 +134,34 @@ public interface Handler {
* @return The cleaner.
*/
Cleaner getCleaner();
/**
* Get a localized string.
*
* @param key The key.
* @return The string.
*/
String getLocalizedString(@NotNull NamespacedKey key);
/**
* Add new plugin.
*
* @param plugin The plugin.
*/
void addNewPlugin(@NotNull EcoPlugin plugin);
/**
* Get plugin by name.
*
* @param name The name.
* @return The plugin.
*/
EcoPlugin getPluginByName(@NotNull String name);
/**
* Get all loaded eco plugins.
*
* @return A list of plugin names in lowercase.
*/
List<String> getLoadedPlugins();
}

View File

@@ -1,9 +1,11 @@
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;
@@ -42,8 +44,8 @@ public class StringUtils {
/**
* Translate a list of strings - converts Placeholders and Color codes.
*
* @param list The messages to translate.
* @param player The player to translate placeholders with respect to.
* @param list The messages to translate.
* @param player The player to translate placeholders with respect to.
* @return The message, translated.
*/
public List<String> translateList(@NotNull final List<String> list,
@@ -246,4 +248,14 @@ 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);
}
}