Performance Improvements (#340)

* Performance Improvements

* More Optimizations

* Even More Optimizations & Cleanups

* Almost a recode I guess
This commit is contained in:
Crypto Morin
2020-07-16 09:32:22 -07:00
committed by GitHub
parent f9f59f1f96
commit 54d5757d0a
52 changed files with 876 additions and 875 deletions

View File

@@ -26,11 +26,11 @@ import me.clip.placeholderapi.PlaceholderHook;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import java.util.List;
public abstract class PlaceholderExpansion extends PlaceholderHook {
/**
* The name of this expansion
*
@@ -123,60 +123,58 @@ public abstract class PlaceholderExpansion extends PlaceholderHook {
}
/**
* Quick getter for the {@link PlaceholderAPIPlugin} instance
* Quick getter for the {@link PlaceholderAPIPlugin} config.
*
* @return {@link PlaceholderAPIPlugin} instance
* @return {@link PlaceholderAPIPlugin} config instance.
*/
public PlaceholderAPIPlugin getPlaceholderAPI() {
return PlaceholderAPIPlugin.getInstance();
public FileConfiguration getConfig() {
return PlaceholderAPIPlugin.getInstance().getConfig();
}
public String getString(String path, String def) {
return getPlaceholderAPI().getConfig()
.getString("expansions." + getIdentifier() + "." + path, def);
return getConfig().getString(getPathStarter() + path, def);
}
public int getInt(String path, int def) {
return getPlaceholderAPI().getConfig()
.getInt("expansions." + getIdentifier() + "." + path, def);
return getConfig().getInt(getPathStarter() + path, def);
}
public long getLong(String path, long def) {
return getPlaceholderAPI().getConfig()
.getLong("expansions." + getIdentifier() + "." + path, def);
return getConfig().getLong(getPathStarter() + path, def);
}
public double getDouble(String path, double def) {
return getPlaceholderAPI().getConfig()
.getDouble("expansions." + getIdentifier() + "." + path, def);
return getConfig().getDouble(getPathStarter() + path, def);
}
public List<String> getStringList(String path) {
return getPlaceholderAPI().getConfig()
.getStringList("expansions." + getIdentifier() + "." + path);
return getConfig().getStringList(getPathStarter() + path);
}
public Object get(String path, Object def) {
return getPlaceholderAPI().getConfig().get("expansions." + getIdentifier() + "." + path, def);
return getConfig().get(getPathStarter() + path, def);
}
public ConfigurationSection getConfigSection(String path) {
return getPlaceholderAPI().getConfig()
.getConfigurationSection("expansions." + getIdentifier() + "." + path);
return getConfig().getConfigurationSection(getPathStarter() + path);
}
public ConfigurationSection getConfigSection() {
return getPlaceholderAPI().getConfig().getConfigurationSection("expansions." + getIdentifier());
return getConfig().getConfigurationSection("expansions." + getIdentifier());
}
public boolean configurationContains(String path) {
return getPlaceholderAPI().getConfig().contains("expansions." + getIdentifier() + "." + path);
return getConfig().contains(getPathStarter() + path);
}
protected String getPathStarter() {
return "expansions." + getIdentifier() + '.';
}
/**
* @deprecated As of versions greater than 2.8.7, use {@link #getRequiredPlugin()}
*/
@SuppressWarnings("DeprecatedIsStillUsed")
@Deprecated
public String getPlugin() {
return null;