Loft configuration behaviour for command executors

This commit is contained in:
Gabriel Tofvesson 2021-05-04 05:54:51 +02:00
parent 0e8ab30672
commit 3ab058adfb

View File

@ -0,0 +1,32 @@
package dev.w1zzrd.invtweaks.command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.plugin.Plugin;
public abstract class ConfigurableCommandExecutor<T extends ConfigurationSerializable> implements CommandExecutor {
private final Plugin plugin;
private final String path;
private T config;
public ConfigurableCommandExecutor(
final Plugin plugin,
final String path
) {
this.plugin = plugin;
this.path = path;
reloadConfig();
}
public void reloadConfig() {
config = (T) plugin.getConfig().get(path, plugin.getConfig().getDefaults().get(path));
}
protected T getConfig() {
return config;
}
protected Plugin getPlugin() {
return plugin;
}
}