Add reload command

This commit is contained in:
Ryder Belserion 2023-07-20 22:23:14 -04:00
parent e9fe8d97f6
commit a66c036289
No known key found for this signature in database
GPG Key ID: 6F86975AD74B46E5
3 changed files with 49 additions and 2 deletions

View File

@ -20,7 +20,7 @@ public class ApiManager {
private static SettingsManager config;
private static SettingsManager pluginConfig;
public ApiManager load() {
public void load() {
File pluginConfigFile = new File(this.path.toFile(), "plugin-config.yml");
pluginConfig = SettingsManagerBuilder
@ -49,11 +49,23 @@ public class ApiManager {
.configurationData(ConfigBuilder.buildConfig())
.create();
return this;
}
public void reload() {
// Reload configs.
pluginConfig.reload();
config.reload();
locale.reload();
File localeDir = new File(this.path.toFile(), "locale");
File localeFile = new File(localeDir, pluginConfig.getProperty(PluginConfig.LOCALE_FILE) + ".yml");
locale = SettingsManagerBuilder
.withYamlFile(localeFile)
.useDefaultMigrationService()
.configurationData(ConfigBuilder.buildLocale())
.create();
}
public static SettingsManager getPluginConfig() {

View File

@ -9,5 +9,19 @@ public class CrazyManager {
public void load() {
// Used for user data.
init();
}
public void reload(boolean serverStop) {
if (!serverStop) {
// Used for user data.
init();
}
}
private void init() {
}
}

View File

@ -0,0 +1,21 @@
package com.badbones69.crazyauctions.commands.admin;
import com.badbones69.crazyauctions.CrazyAuctions;
import com.badbones69.crazyauctions.api.frame.command.CommandContext;
import com.badbones69.crazyauctions.api.frame.command.CommandEngine;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.Collections;
public class CommandReload extends CommandEngine {
private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
public CommandReload() {
super("reload", "Reloads the plugin.", "/crazyauctions:reload", Collections.emptyList());
}
@Override
protected void perform(CommandContext context, String[] args) {
}
}