Remove Config related methods in SongodaPlugin

Escept for #getExtraConfigs which got renamed, the other methods are no longer required and have been removed.

Additionally the config methods defined by Bukkit's JavaPlugin class
have been overwritten with empty bodies.
This prevents the default behaviour trying to access stuff that's not there
or should not be considered a valid config to use.
This commit is contained in:
Christian Koop 2022-06-26 02:38:29 +02:00
parent 4bc0e991ab
commit fce5c5c6a1
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3
3 changed files with 35 additions and 33 deletions

View File

@ -1,15 +1,16 @@
package com.songoda.core;
import com.songoda.core.configuration.Config;
import com.songoda.core.configuration.songoda.SongodaYamlConfig;
import com.songoda.core.database.DataManagerAbstract;
import com.songoda.core.locale.Locale;
import com.songoda.core.utils.Metrics;
import de.tr7zw.changeme.nbtapi.utils.MinecraftVersion;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.concurrent.TimeUnit;
@ -21,7 +22,6 @@ import java.util.logging.Level;
*/
public abstract class SongodaPlugin extends JavaPlugin {
protected Locale locale;
protected Config config = new Config(this);
protected long dataLoadDelay = 20L;
private boolean emergencyStop = false;
@ -41,36 +41,14 @@ public abstract class SongodaPlugin extends JavaPlugin {
public abstract void onDataLoad();
/**
* Called after reloadConfig() is called
* All the configuration files belonging to the plugin.<br>
* This might for example be used for the ingame config editor.<br>
* <br>
* Do not include *storage* files here or anything similar that does not intend external modification and access.<br>
* <br>
* Do not include language files if you are using the Core's localization system.
*/
public abstract void onConfigReload();
/**
* Any other plugin configuration files used by the plugin.
*
* @return a list of Configs that are used in addition to the main config.
*/
public abstract List<Config> getExtraConfig();
@Override
public FileConfiguration getConfig() {
return config.getFileConfig();
}
public Config getCoreConfig() {
return config;
}
@Override
public void reloadConfig() {
config.load();
onConfigReload();
}
@Override
public void saveConfig() {
config.save();
}
public abstract List<SongodaYamlConfig> getConfigs();
@Override
public final void onLoad() {
@ -235,4 +213,27 @@ public abstract class SongodaPlugin extends JavaPlugin {
emergencyStop();
}
/**
* Use {@link SongodaYamlConfig} instead.
*/
@NotNull
@Override
public FileConfiguration getConfig() {
return super.getConfig();
}
/**
* Use {@link SongodaYamlConfig} instead.
*/
@Override
public void reloadConfig() {
}
/**
* Use {@link SongodaYamlConfig} instead.
*/
@Override
public void saveConfig() {
}
}

View File

@ -35,7 +35,7 @@ public class PluginConfigGui extends SimplePagedGui {
// collect list of plugins
configs.put(plugin.getCoreConfig().getFile().getName(), plugin.getCoreConfig());
List<Config> more = plugin.getExtraConfig();
List<Config> more = plugin.getConfigs();
if (more != null && !more.isEmpty()) {
for (Config cfg : more) {
configs.put(cfg.getFile().getName(), cfg);

View File

@ -24,6 +24,7 @@ import java.util.function.Supplier;
import java.util.logging.Level;
import java.util.logging.Logger;
// TODO: Allow registering load-Listeners
public class SongodaYamlConfig extends YamlConfiguration {
protected final String cannotCreateBackupCopyExceptionPrefix = "Unable to create backup copy of config file: ";