Update configurations

Changes:
  - Inherit the plugin variable through the interface
  - Add e.printStackTrace()
  - Update config comments for the storage-method ( Block Comments cannot be used on Java 8 )
This commit is contained in:
Ryder Belserion 2023-02-19 13:03:32 -05:00
parent ba6a47e667
commit 7ba7110b57
No known key found for this signature in database
GPG Key ID: 8FC2E6C54BBF05FE
4 changed files with 27 additions and 14 deletions

View File

@ -53,8 +53,8 @@ public class CrazyAuctions extends JavaPlugin implements RubyCore {
@Override
public void onEnable() {
Config.reload(this);
Locale.reload(this);
Config.reload();
Locale.reload();
AuctionData.load();
@ -76,7 +76,6 @@ public class CrazyAuctions extends JavaPlugin implements RubyCore {
/**
* These all can be null as we don't use them here.
*/
@Override
public @NotNull Console getConsole() {
return null;

View File

@ -1,6 +1,7 @@
package com.badbones69.crazyauctions.configs;
import com.badbones69.crazyauctions.CrazyAuctions;
import com.badbones69.crazyauctions.api.interfaces.Universal;
import net.dehya.ruby.common.annotations.FileBuilder;
import net.dehya.ruby.common.annotations.yaml.BlockType;
import net.dehya.ruby.common.annotations.yaml.Comment;
@ -12,7 +13,7 @@ import org.simpleyaml.configuration.file.YamlFile;
import java.io.IOException;
@FileBuilder(isLogging = true, isAsync = false, isData = false, fileType = FileType.YAML)
public class Config extends FileExtension {
public class Config extends FileExtension implements Universal {
@Key("settings.prefix")
@Comment("The prefix used in front of messages.")
@ -35,15 +36,15 @@ public class Config extends FileExtension {
@Comment("DO NOT TOUCH THIS: We use this to identify if your configs are outdated.")
public static double CONFIG_VERSION = 1.0;
@Key("settings.storage-type")
@Comment("Choose what type of storage option for the data to use. FLAT/MYSQL/<TBD>")
public static String STORAGE_TYPE = "FLAT";
@Key("settings.data-storage.storage-method")
@Comment("The only available type at the moment is JSON")
public static String STORAGE_TYPE = "JSON";
public Config() {
super("config.yml");
}
public static void reload(CrazyAuctions plugin) {
public static void reload() {
plugin.getSpigotFileManager().addFile(new Config());
}
@ -51,10 +52,9 @@ public class Config extends FileExtension {
try {
return fileManager.getFileConfiguration(new Config());
} catch (IOException e) {
//Error Message goes here
e.printStackTrace();
}
return null;
}
}

View File

@ -1,19 +1,19 @@
package com.badbones69.crazyauctions.configs;
import com.badbones69.crazyauctions.CrazyAuctions;
import com.badbones69.crazyauctions.api.interfaces.Universal;
import net.dehya.ruby.common.annotations.FileBuilder;
import net.dehya.ruby.common.enums.FileType;
import net.dehya.ruby.files.FileExtension;
import java.nio.file.Path;
@FileBuilder(isLogging = true, isAsync = false, isData = false, fileType = FileType.YAML)
public class Locale extends FileExtension {
public class Locale extends FileExtension implements Universal {
public Locale(Path path) {
super(Config.LOCALE_FILE, path.resolve("locale"));
}
public static void reload(CrazyAuctions plugin) {
public static void reload() {
plugin.getSpigotFileManager().extract("/locale", plugin.getDirectory());
plugin.getSpigotFileManager().addFile(new Locale(plugin.getDirectory()));

View File

@ -6,4 +6,18 @@ settings:
update-checker: true # Whether you want to be notified when an update is published to Modrinth.
toggle-metrics: true # Whether you want your server statistics to be sent to https://bstats.org/ ( Requires a restart! )
config-version: 1.0 # DO NOT TOUCH THIS: We use this to identify if configs are outdated.
storage-type: 'FLAT' #Choose what type of storage option for the data to use. FLAT/MYSQL/<TBD>
data-storage:
# How the plugin should store data
#
# - Your Options
# | Remote Database Types - You need to supply connection information.
# |» MySQL *NOT IMPLEMENTED*
# |» MariaDB ( Recommended over MySQL ) *NOT IMPLEMENTED*
#
# | Local Database Types
# |» H2 *NOT IMPLEMENTED*
#
# | Text File Based Storage
# |» JSON (.json files) *DEFAULT
storage-method: JSON