this method loops through all the available materials and matches their ID using XMaterial.getId()
- which takes a really long time. Plugins should no longer support IDs. If you want, you can make a Map cache yourself.
- This method obviously doesn't work for 1.13+ and will not be supported. This is only here for debugging purposes.
Gets the value of the path as keys
If deep is set to true, then this will contain all the keys within any child ConfigurationSections (and their children, etc).
this method loops through all the available materials and matches their ID using XMaterial.getId()
- which takes a really long time. Plugins should no longer support IDs. If you want, you can make a Map cache yourself.
- This method obviously doesn't work for 1.13+ and will not be supported. This is only here for debugging purposes.
The PluginInjector works with Songoda and Spigot Products,
- this will help you to check information of a download, for example:
- The Identifier of a user who downloaded this plugin, or the id of the resource,
- or the nonce of the download.
Constructor of the ConfigurationField
-
- If the specified Configuration doesn't have the specified path
- this util will set the specified default value.
This will return the language display name in his own language
-
- If the language is es_ES it will return "Español",
- if the language is en_US it will return "English"
Constructor of the ConfigurationField
-
- If the specified Configuration doesn't have the specified path
- this util will set the specified default value.
public ConfigurationField(net.md_5.bungee.config.Configuration configuration,
- java.lang.String path,
- java.lang.Object defaultValue)
-
Constructor of the ConfigurationField
-
- If the specified Configuration doesn't have the specified path
- this util will set the specified default value.
The PluginInjector works with Songoda and Spigot Products,
- this will help you to check information of a download, for example:
- The Identifier of a user who downloaded this plugin, or the id of the resource,
- or the nonce of the download.
Gets the value of the path as keys
If deep is set to true, then this will contain all the keys within any child ConfigurationSections (and their children, etc).
This will return the language display name in his own language
-
- If the language is es_ES it will return "Español",
- if the language is en_US it will return "English"
This will return the language display name in his own language
-
- If the language is es_ES it will return "Español",
- if the language is en_US it will return "English"
A reflection API for action bars in Minecraft.
- Fully optimized - Supports 1.8.8+ and above.
- Requires ReflectionUtils.
- Messages are not colorized by default.
-
- Action bars are text messages that appear above
- the player's hotbar
- Note that this is different than the text appeared when switching between items.
- Those messages show the item's name and are different from action bars.
- The only natural way of displaying action bars is when mounting.
-
- Action bars cannot fade or stay like titles.
- For static Action bars you'll need to send the packet every
- 2 seconds (40 ticks) for it to stay on the screen without fading.
-
A reflection API for titles in Minecraft.
- Fully optimized - Supports 1.8.8+ and above.
- Requires ReflectionUtils.
- Messages are not colorized by default.
-
- Titles are text messages that appear in the
- middle of the players screen: https://minecraft.gamepedia.com/Commands/title
- PacketPlayOutTitle: https://wiki.vg/Protocol#Title
- This class will throw a "unsupported material" error if someone tries to use an item with an invalid data value which can only happen in 1.12 servers and below or when the
- utility is missing a new material in that specific version.
- To get an invalid item, (aka Missing Texture Block) you can use the command
- /give @p minecraft:dirt 1 10 where 1 is the item amount, and 10 is the data value. The material DIRT with a data value of 10 doesn't exist.
We will only add "INK_SAC" for BLACK_DYE since it's
- the only material (linked with this material) that is added
- after 1.13, which means it can use both INK_SACK and INK_SAC.
Adding this to the duplicated list will give you a filled map
- for 1.13+ versions and removing it from duplicated list will
- still give you a filled map in -1.12 versions.
this method loops through all the available materials and matches their ID using getId()
- which takes a really long time. Plugins should no longer support IDs. If you want, you can make a Map cache yourself.
- This method obviously doesn't work for 1.13+ and will not be supported. This is only here for debugging purposes.
For some reasons filled map items are really special.
- Their data value starts from 0 and every time a player
- creates a new map that maps data value increases.
We will only add "INK_SAC" for BLACK_DYE since it's
- the only material (linked with this material) that is added
- after 1.13, which means it can use both INK_SACK and INK_SAC.
Adding this to the duplicated list will give you a filled map
- for 1.13+ versions and removing it from duplicated list will
- still give you a filled map in -1.12 versions.
- Since higher versions are our priority I'll keep 1.13+ support
- until I can come up with something to fix it.
Just like mentioned in https://minecraft.gamepedia.com/Nether_Wart
- Nether wart is also known as nether stalk in the code.
- NETHER_STALK is the planted state of nether warts.
This is used for blocks only.
- In 1.13- WATER will turn into STATIONARY_WATER after it finished spreading.
- After 1.13+ this uses
- https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/data/Levelled.html water flowing system.
- Use XBlock for this instead.
Returns an array containing the constants of this enum type, in
-the order they are declared. This method may be used to iterate
-over the constants as follows:
-
-for (XMaterial c : XMaterial.values())
- System.out.println(c);
-
-
-
Returns:
-
an array containing the constants of this enum type, in the order they are declared
public static XMaterial valueOf(java.lang.String name)
-
Returns the enum constant of this type with the specified name.
-The string must match exactly an identifier used to declare an
-enum constant in this type. (Extraneous whitespace characters are
-not permitted.)
-
-
Parameters:
-
name - the name of the enum constant to be returned.
-
Returns:
-
the enum constant with the specified name
-
Throws:
-
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
-
java.lang.NullPointerException - if the argument is null
This is just an extra method that method that can be used for many cases.
- It can be used in PlayerInteractEvent
- or when accessing HumanEntity.getMainHand(),
- or other compatibility related methods.
-
- An invocation of this method yields exactly the same result as the expression:
-
Deprecated.this method loops through all the available materials and matches their ID using getId()
- which takes a really long time. Plugins should no longer support IDs. If you want, you can make a Map cache yourself.
- This method obviously doesn't work for 1.13+ and will not be supported. This is only here for debugging purposes.
-
Gets the XMaterial based on the material's ID (Magic Value) and data value.
- You should avoid using this for performance issues.
-
-
Parameters:
-
id - the ID (Magic value) of the material.
-
data - the data value of the material.
-
Returns:
-
a parsed XMaterial with the same ID and data value.
Attempts to build the string like an enum name.
- Removes all the spaces, and extra non-English characters. Also removes some config/in-game based strings.
- While this method is hard to maintain, it's extremely efficient. It's approximately more than x5 times faster than
- the normal RegEx + String Methods approach for both formatted and unformatted material names.
- "REGEX:^.+_.+_.+$" -> Every Material with 3 underlines or more: SHULKER_SPAWN_EGG, SILVERFISH_SPAWN_EGG, SKELETON_HORSE_SPAWN_EGG
- "REGEX:^.{1,3}$" -> Material names that have 3 letters only: BED, MAP, AIR
-
-
- The reason that there are tags for CONTAINS and REGEX is for the performance.
- Although RegEx patterns are cached in this method,
- please avoid using the REGEX tag if you can use the CONTAINS tag instead.
- It'll have a huge impact on performance.
- Please avoid using (capturing groups) there's no use for them in this case.
- If you want to use groups, use (?: non-capturing groups). It's faster.
-
- Want to learn RegEx? You can mess around in RegExr website.
-
-
Parameters:
-
materials - the material names to check base material on.
-
Returns:
-
true if one of the given material names is similar to the base material.
The version this material was added in. This will return the minor number in the version scheme.
- For example, if it was added in 1.16, it'll return 16
-
-
Returns:
-
the version number of 0 if the version was not recorded.
-
-
-
diff --git a/pom.xml b/pom.xml
index bc77bdfd..2066cfe4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
xyz.theprogramsrcSuperCoreAPI
- 5.0.1-SNAPSHOT
+ 5.0.0-SNAPSHOTjarSuperCoreAPI
@@ -62,6 +62,18 @@
com.cryptomorin.xseriesxyz.theprogramsrc.supercoreapi.libs.xseries
+
+ org.simpleyaml
+ xyz.theprogramsrc.supercoreapi.libs.simpleyaml
+
+
+ org.yaml.snakeyaml
+ xyz.theprogramsrc.supercoreapi.libs.snakeyaml
+
+
+ org.slf4j
+ xyz.theprogramsrc.supercoreapi.libs.slf4j
+
@@ -149,14 +161,14 @@
org.spigotmcspigot-api
- 1.16.5-R0.1-SNAPSHOT
+ 1.17-R0.1-SNAPSHOTprovidednet.md-5bungeecord-api
- 1.16-R0.5-SNAPSHOT
+ 1.17-R0.1-SNAPSHOTprovided
@@ -206,6 +218,13 @@
2.8.6compile
+
+
+ me.carleslc.Simple-YAML
+ Simple-Yaml
+ 1.7.2
+ compile
+ com.zaxxer
diff --git a/src/main/java/xyz/theprogramsrc/supercoreapi/bungee/BungeePlugin.java b/src/main/java/xyz/theprogramsrc/supercoreapi/bungee/BungeePlugin.java
index 04fb6d30..79dbfad4 100644
--- a/src/main/java/xyz/theprogramsrc/supercoreapi/bungee/BungeePlugin.java
+++ b/src/main/java/xyz/theprogramsrc/supercoreapi/bungee/BungeePlugin.java
@@ -67,7 +67,7 @@ public void onEnable() {
this.debug("Loading Settings");
this.settings = new Settings();
this.debug("Loading Translations");
- this.translationsFolder = Utils.folder(new File(this.getDataFolder(), "translations/"));
+ this.translationsFolder = Utils.folder(new File(this.getDataFolder(), "lang/"));
this.translationManager = new TranslationManager(this);
this.getTranslationManager().registerTranslation(Base.class);
this.debug("Loading EventManager");
diff --git a/src/main/java/xyz/theprogramsrc/supercoreapi/bungee/storage/Settings.java b/src/main/java/xyz/theprogramsrc/supercoreapi/bungee/storage/Settings.java
index 300e6b02..01d1ed1d 100644
--- a/src/main/java/xyz/theprogramsrc/supercoreapi/bungee/storage/Settings.java
+++ b/src/main/java/xyz/theprogramsrc/supercoreapi/bungee/storage/Settings.java
@@ -1,20 +1,20 @@
package xyz.theprogramsrc.supercoreapi.bungee.storage;
import xyz.theprogramsrc.supercoreapi.bungee.BungeeModule;
-import xyz.theprogramsrc.supercoreapi.bungee.utils.storage.BungeeYMLConfig;
+import xyz.theprogramsrc.supercoreapi.global.files.yml.YMLConfig;
/**
* Basic BungeeCord Settings used by the Plugin
*/
public class Settings extends BungeeModule {
- private BungeeYMLConfig config;
+ private YMLConfig config;
private String defaultPrefix;
@Override
public void onLoad() {
- this.config = new BungeeYMLConfig(this.getPluginFolder(), "Settings.yml");
+ this.config = new YMLConfig(this.getPluginFolder(), "Settings.yml");
this.defaultPrefix = "&9" + this.getPluginName() + "»&r";
if(this.plugin.isFirstStart()){
this.loadDefaults();
@@ -37,12 +37,12 @@ public String getPrefix(){
return this.config.getString("Prefix", this.defaultPrefix);
}
- public BungeeYMLConfig getConfig() {
+ public YMLConfig getConfig() {
return config;
}
public void loadDefaults(){
this.config.add("Prefix", this.defaultPrefix);
- this.config.add("Language","en_US");
+ this.config.add("Language","en");
}
}
diff --git a/src/main/java/xyz/theprogramsrc/supercoreapi/bungee/utils/storage/BungeeYMLConfig.java b/src/main/java/xyz/theprogramsrc/supercoreapi/bungee/utils/storage/BungeeYMLConfig.java
deleted file mode 100644
index 333b4bdb..00000000
--- a/src/main/java/xyz/theprogramsrc/supercoreapi/bungee/utils/storage/BungeeYMLConfig.java
+++ /dev/null
@@ -1,469 +0,0 @@
-package xyz.theprogramsrc.supercoreapi.bungee.utils.storage;
-
-import net.md_5.bungee.config.Configuration;
-import net.md_5.bungee.config.ConfigurationProvider;
-import net.md_5.bungee.config.YamlConfiguration;
-import xyz.theprogramsrc.supercoreapi.global.utils.Utils;
-
-import java.io.File;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Used to generate and work with YAML files
- */
-public class BungeeYMLConfig {
- private Configuration config;
- private final File file;
-
- /**
- * Create a new YML Config using a File
- *
- * @param file The file where should be all the data
- */
- public BungeeYMLConfig(File file){
- this.file = file;
- this.load();
- }
-
- /**
- * Create a new YML Config using a folder and the File Name
- *
- * @param folder The folder where should be placed the file
- * @param fileName The name of the file (including the extension)
- */
- public BungeeYMLConfig(File folder, String fileName){
- this(new File(Utils.folder(folder), fileName));
- }
-
- private void load(){
- try {
- if(!this.file.exists()) this.file.createNewFile();
- this.config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file);
- }catch (Exception ex){
- ex.printStackTrace();
- }
- }
-
- /**
- * Delete the file and his contents
- * and then create a new file
- */
- public void clear(){
- try{
- Utils.destroyFile(this.file);
- if(!this.file.exists())this.file.createNewFile();
- this.reload();
- }catch (Exception ex){
- ex.printStackTrace();
- }
- }
-
- /**
- * Used to reload the cache
- * Note: All unsaved changes will be erased
- *
- * @see #save()
- */
- public void reload(){
- try{
- this.config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file);
- }catch (Exception ex){
- ex.printStackTrace();
- }
- }
-
- /**
- * Used to save all the changes made
- *
- */
- public void save(){
- try{
- ConfigurationProvider.getProvider(YamlConfiguration.class).save(this.config, this.file);
- }catch (Exception ex){
- ex.printStackTrace();
- }
- }
-
- /**
- * Used to set information inside the file
- *
- * @param path Location of the saved information
- * @param value Information to save
- */
- public void set(String path, Object value){
- if(value instanceof Float){
- float val = ((float) value);
- value = Float.toString(val);
- }
- this.config.set(path, value);
- this.save();
- }
-
- /**
- * Used to add information inside the file
- * ONLY IF DOES NOT EXISTS
- *
- * @param path Location of the saved information
- * @param value Information to save
- */
- public void add(String path, Object value){
- if(!this.contains(path)) this.set(path, value);
- }
-
- /**
- * Used to check if the configuration contains a specific Path
- *
- * @param path Path to check
- * @return true if the path exists, otherwise false
- */
- public boolean contains(String path){
- return this.config.contains(path);
- }
-
- /**
- * Used to request information from the file
- *
- * @param path Path where is saved the information
- * @return The information saved in the specified path
- */
- public Object get(String path){
- return this.config.get(path);
- }
-
- /**
- * Used to request information from the file, and if not exists set the default value
- *
- * @param path Path where is saved the information
- * @param def Object to save if there is no existent information in the path
- * @return The information saved in the specified path
- */
- public Object get(String path, Object def){
- this.add(path, def);
- return this.get(path);
- }
-
- /**
- * Used to request information from the file
- *
- * @param path Path where is saved the information
- * @return The information saved in the specified path
- */
- public String getString(String path){
- return this.config.getString(path);
- }
-
- /**
- * Used to request information from the file, and if not exists set the default value
- *
- * @param path Path where is saved the information
- * @param def Object to save if there is no existent information in the path
- * @return The information saved in the specified path
- */
- public String getString(String path, String def){
- this.add(path, def);
- return this.getString(path);
- }
-
- /**
- * Used to request information from the file
- *
- * @param path Path where is saved the information
- * @return The information saved in the specified path
- */
- public boolean getBoolean(String path){
- return this.config.getBoolean(path);
- }
-
- /**
- * Used to request information from the file, and if not exists set the default value
- *
- * @param path Path where is saved the information
- * @param def Object to save if there is no existent information in the path
- * @return The information saved in the specified path
- */
- public boolean getBoolean(String path, boolean def){
- this.add(path, def);
- return this.getBoolean(path);
- }
-
- /**
- * Used to request information from the file
- *
- * @param path Path where is saved the information
- * @return The information saved in the specified path
- */
- public int getInt(String path){
- return this.config.getInt(path);
- }
-
- /**
- * Used to request information from the file, and if not exists set the default value
- *
- * @param path Path where is saved the information
- * @param def Object to save if there is no existent information in the path
- * @return The information saved in the specified path
- */
- public int getInt(String path, int def){
- this.add(path, def);
- return this.getInt(path);
- }
-
- /**
- * Used to request information from the file
- *
- * @param path Path where is saved the information
- * @return The information saved in the specified path
- */
- public double getDouble(String path){
- return this.config.getDouble(path);
- }
-
- /**
- * Used to request information from the file, and if not exists set the default value
- *
- * @param path Path where is saved the information
- * @param def Object to save if there is no existent information in the path
- * @return The information saved in the specified path
- */
- public double getDouble(String path, double def){
- this.add(path,def);
- return this.getDouble(path);
- }
-
- /**
- * Used to request information from the file
- *
- * @param path Path where is saved the information
- * @return The information saved in the specified path
- */
- public long getLong(String path){
- return this.config.getLong(path);
- }
-
- /**
- * Used to request information from the file, and if not exists set the default value
- *
- * @param path Path where is saved the information
- * @param def Object to save if there is no existent information in the path
- * @return The information saved in the specified path
- */
- public long getLong(String path, long def){
- this.add(path, def);
- return this.getLong(path);
- }
-
- /**
- * Used to request information from the file
- *
- * @param path Path where is saved the information
- * @return The information saved in the specified path
- */
- public float getFloat(String path){
- return Long.parseLong(this.getString(path));
- }
-
- /**
- * Used to request information from the file, and if not exists set the default value
- *
- * @param path Path where is saved the information
- * @param def Object to save if there is no existent information in the path
- * @return The information saved in the specified path
- */
- public float getFloat(String path, float def){
- this.add(path, def);
- return this.getFloat(path);
- }
-
- /**
- * Used to request information from the file
- *
- * @param path Path where is saved the information
- * @return The information saved in the specified path
- */
- public List> getList(String path){
- return this.config.getList(path);
- }
-
- /**
- * Used to request information from the file, and if not exists set the default value
- *
- * @param path Path where is saved the information
- * @param def Object to save if there is no existent information in the path
- * @return The information saved in the specified path
- */
- public List> getList(String path, List> def){
- this.add(path, def);
- return this.getList(path);
- }
-
- /**
- * Used to request information from the file
- *
- * @param path Path where is saved the information
- * @return The information saved in the specified path
- */
- public List getStringList(String path){
- return this.config.getStringList(path);
- }
-
- /**
- * Used to request information from the file, and if not exists set the default value
- *
- * @param path Path where is saved the information
- * @param def Object to save if there is no existent information in the path
- * @return The information saved in the specified path
- */
- public List getStringList(String path, List def){
- this.add(path, def);
- return this.getStringList(path);
- }
-
- /**
- * Used to request information from the file
- *
- * @param path Path where is saved the information
- * @return The information saved in the specified path
- */
- public List getBooleanList(String path){
- return this.config.getBooleanList(path);
- }
-
- /**
- * Used to request information from the file, and if not exists set the default value
- *
- * @param path Path where is saved the information
- * @param def Object to save if there is no existent information in the path
- * @return The information saved in the specified path
- */
- public List getBooleanList(String path, List def){
- this.add(path, def);
- return this.getBooleanList(path);
- }
-
- /**
- * Used to request information from the file
- *
- * @param path Path where is saved the information
- * @return The information saved in the specified path
- */
- public List getIntList(String path){
- return this.config.getIntList(path);
- }
-
- /**
- * Used to request information from the file, and if not exists set the default value
- *
- * @param path Path where is saved the information
- * @param def Object to save if there is no existent information in the path
- * @return The information saved in the specified path
- */
- public List getIntList(String path, List def){
- this.add(path, def);
- return this.getIntList(path);
- }
-
- /**
- * Used to request information from the file
- *
- * @param path Path where is saved the information
- * @return The information saved in the specified path
- */
- public List getDoubleList(String path){
- return this.config.getDoubleList(path);
- }
-
- /**
- * Used to request information from the file, and if not exists set the default value
- *
- * @param path Path where is saved the information
- * @param def Object to save if there is no existent information in the path
- * @return The information saved in the specified path
- */
- public List getDoubleList(String path, List def){
- this.add(path, def);
- return this.getDoubleList(path);
- }
-
- /**
- * Used to request information from the file
- *
- * @param path Path where is saved the information
- * @return The information saved in the specified path
- */
- public List getLongList(String path){
- return this.config.getLongList(path);
- }
-
- /**
- * Used to request a {@link Long list of longs} from the file, and if not exists set the default value
- *
- * @param path Path where is saved the {@link Long list of longs}
- * @param def Object to save if there is no existent {@link Long list of longs} in the path
- * @return The {@link Long list of longs} saved in the specified path
- */
- public List getLongList(String path, List def){
- this.add(path, def);
- return this.getLongList(path);
- }
-
- /**
- * Used to request a {@link Float list of floats} from the file
- *
- * @param path Path where is saved the {@link Float list of floats}
- * @return The {@link Float list of floats} saved in the specified path
- */
- public List getFloatList(String path){
- return this.config.getFloatList(path);
- }
-
- /**
- * Used to request a list of Floats from the file, and if not exists set the default value
- *
- * @param path Path where is saved the float list
- * @param def Object to save if there is no existent float list in the path
- * @return The float list saved in the specified path
- */
- public List getFloatList(String path, List def){
- this.add(path, def);
- return this.getFloatList(path);
- }
-
- /**
- * Used to request a {@link Configuration Configuration Section} from the file
- *
- * @param path Path where is saved the {@link Configuration}
- * @return The {@link Configuration} saved in the specified path
- */
- public Configuration getSection(String path){
- return this.config.getSection(path);
- }
-
- /**
- * Gets keys, not deep by default.
- *
- * @return top level keys for this section
- */
- public Set getKeys(){
- return new HashSet<>(this.config.getKeys());
- }
-
- /**
- * Used to get the main {@link Configuration Configuration}
- *
- * @return The main {@link Configuration Configuration}
- */
- public Configuration getConfig() {
- return config;
- }
-
- /**
- * Used to get the file containing all the data of the current Configuration
- *
- * @return The {@link File File} containing all the data
- */
- public File getFile() {
- return file;
- }
-}
diff --git a/src/main/java/xyz/theprogramsrc/supercoreapi/bungee/utils/storage/ConfigurationField.java b/src/main/java/xyz/theprogramsrc/supercoreapi/bungee/utils/storage/ConfigurationField.java
deleted file mode 100644
index 0376773c..00000000
--- a/src/main/java/xyz/theprogramsrc/supercoreapi/bungee/utils/storage/ConfigurationField.java
+++ /dev/null
@@ -1,157 +0,0 @@
-package xyz.theprogramsrc.supercoreapi.bungee.utils.storage;
-
-
-import net.md_5.bungee.config.Configuration;
-
-import java.util.Collection;
-import java.util.List;
-
-/**
- * Representation of a Configuration Field
- */
-public class ConfigurationField {
-
- private final Configuration config;
- private final String path;
- private Object def;
-
- /**
- * Constructor of the ConfigurationField
- *
- * If the specified Configuration doesn't have the specified path
- * this util will set the specified default value.
- *
- * @param configuration The configuration
- * @param path The path of the field
- * @param defaultValue The default value if the field
- */
- public ConfigurationField(Configuration configuration, String path, Object defaultValue){
- this.config = configuration;
- this.path = path;
- this.def = defaultValue;
- this.add();
- }
-
- /**
- * Constructor of the ConfigurationField (without default)
- *
- * @param configuration The configuration
- * @param path The path of the field
- */
- public ConfigurationField(Configuration configuration, String path){
- this.config = configuration;
- this.path = path;
- }
-
- private void add() {
- if(!this.config.contains(this.path)) this.config.set(this.path, this.def);
- }
-
- /**
- * Gets the content of the path as String
- * @see #asString()
- *
- * @return The value of the path as String
- */
- public String toString(){
- return this.config.getString(this.path);
- }
-
- /**
- * Gets the content of the path as Object
- * @return The value of the path as Object
- */
- public Object asObject(){
- return this.config.get(this.path);
- }
-
- /**
- * Gets the content of the path as String
- * @return The value of the path as String
- */
- public String asString(){
- return this.toString();
- }
-
- /**
- * Gets the content of the path as Boolean
- * @return The value of the path as Boolean
- */
- public boolean asBoolean(){
- return this.config.getBoolean(this.path);
- }
-
- /**
- * Gets the content of the path as Integer
- * @return The value of the path as Integer
- */
- public int asInt(){
- return this.config.getInt(this.path);
- }
-
- /**
- * Gets the content of the path as Double
- * @return The value of the path as Double
- */
- public double asDouble(){
- return this.config.getDouble(this.path);
- }
-
- /**
- * Gets the content of the path as a List of unknown objects
- * @return The value of the path as a List of unknown objects
- */
- public List> asList(){
- return this.config.getList(this.path);
- }
-
- /**
- * Gets the content of the path as a List of Strings
- * @return The value of the path as a List of string
- */
- public List asStringList(){
- return this.config.getStringList(this.path);
- }
-
- /**
- * Gets the content of the path as a Configuration Section
- * @return The value of the path as a Configuration Section
- */
- public Configuration asSection(){
- return this.config.getSection(this.path);
- }
-
- /**
- * Gets the content of the path as Keys
- * @return The value of the path as Keys
- */
- public Collection asKeys(){
- return this.config.getKeys();
- }
-
- /**
- * Gets the Configuration
- * @return The configuration
- */
- public Configuration getConfig() {
- return config;
- }
-
-
- /**
- * Gets the path
- * @return The path
- */
- public String getPath() {
- return path;
- }
-
- /**
- * Gets the default value of the field
- * @return The default value
- */
- public Object getDef() {
- return def;
- }
-}
-
diff --git a/src/main/java/xyz/theprogramsrc/supercoreapi/global/data/PluginDataStorage.java b/src/main/java/xyz/theprogramsrc/supercoreapi/global/data/PluginDataStorage.java
index 25122a6e..3b319e4d 100644
--- a/src/main/java/xyz/theprogramsrc/supercoreapi/global/data/PluginDataStorage.java
+++ b/src/main/java/xyz/theprogramsrc/supercoreapi/global/data/PluginDataStorage.java
@@ -1,15 +1,8 @@
package xyz.theprogramsrc.supercoreapi.global.data;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonObject;
import xyz.theprogramsrc.supercoreapi.SuperPlugin;
import xyz.theprogramsrc.supercoreapi.global.files.JsonConfig;
-import xyz.theprogramsrc.supercoreapi.global.notifications.Notification;
-import xyz.theprogramsrc.supercoreapi.global.notifications.NotificationCollection;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
import java.util.UUID;
public class PluginDataStorage extends JsonConfig {
@@ -17,6 +10,8 @@ public class PluginDataStorage extends JsonConfig {
public PluginDataStorage(SuperPlugin> plugin){
super(plugin.getPluginFolder(), "PluginData.json");
this.add("stats_id", UUID.randomUUID().toString());
+ this.add("low_resource_usage", false);
+ this.add("share_stats", true);
this.add("debug", "false");
}
@@ -24,32 +19,11 @@ public boolean isDebugEnabled(){
return this.getBoolean("debug");
}
- public void saveNotification(Notification notification){
- JsonArray data = this.getOrCreateArray("notifications");
- data.add(notification.toString());
- this.set("notifications", data);
+ public boolean isLowResourceUsageEnabled(){
+ return this.getBoolean("low_resource_usage");
}
- public void saveNotifications(Notification... notifications){
- Arrays.stream(notifications).forEach(this::saveNotification);
- }
-
- public NotificationCollection getNotifications(){
- JsonArray data = this.getOrCreateArray("notifications");
- List list = new ArrayList<>();
- data.forEach(j->{
- JsonObject json = j.getAsJsonObject();
- Notification not = Notification.builder()
- .setTitle(json.get("title").getAsString())
- .setContent(json.get("content").getAsString())
- .setCreatedAt(json.get("created_at").getAsLong())
- .build();
- list.add(not);
- });
- return new NotificationCollection(list);
- }
-
- public Notification[] getNotificationsArray(){
- return this.getNotifications().get();
+ public boolean isShareStatsEnabled(){
+ return this.getBoolean("share_stats");
}
}
diff --git a/src/main/java/xyz/theprogramsrc/supercoreapi/spigot/utils/storage/ConfigField.java b/src/main/java/xyz/theprogramsrc/supercoreapi/global/files/yml/ConfigField.java
similarity index 64%
rename from src/main/java/xyz/theprogramsrc/supercoreapi/spigot/utils/storage/ConfigField.java
rename to src/main/java/xyz/theprogramsrc/supercoreapi/global/files/yml/ConfigField.java
index 4056fe1d..fc4209bf 100644
--- a/src/main/java/xyz/theprogramsrc/supercoreapi/spigot/utils/storage/ConfigField.java
+++ b/src/main/java/xyz/theprogramsrc/supercoreapi/global/files/yml/ConfigField.java
@@ -1,7 +1,7 @@
-package xyz.theprogramsrc.supercoreapi.spigot.utils.storage;
+package xyz.theprogramsrc.supercoreapi.global.files.yml;
-import org.bukkit.configuration.ConfigurationSection;
-import org.bukkit.configuration.file.FileConfiguration;
+import org.simpleyaml.configuration.ConfigurationSection;
+import org.simpleyaml.configuration.comments.CommentType;
import java.util.List;
import java.util.Set;
@@ -11,35 +11,59 @@
*/
public class ConfigField {
- private final FileConfiguration config;
+ private final YMLConfig config;
private final String path;
- private Object def;
+ private final Object def;
/**
* Constructor of the ConfigField. If the specified path doesn't exists or is empty, it will be filled with the default value
* @param configuration the configuration
* @param path the path
* @param defaultValue the default value
+ * @param comment the comment to add to the field
+ * @param commentType the type of comment to add
*/
- public ConfigField(FileConfiguration configuration, String path, Object defaultValue){
+ public ConfigField(YMLConfig configuration, String path, Object defaultValue, String comment, CommentType commentType){
this.config = configuration;
this.path = path;
this.def = defaultValue;
- this.add();
+ if(this.def != null){
+ this.config.add(this.path, this.def);
+ }
+
+ if(comment != null){
+ this.config.addComment(path, comment, commentType);
+ }
}
/**
- * Constructor of the ConfigField (Without default value)
+ * Constructor of the ConfigField. If the specified path doesn't exists or is empty, it will be filled with the default value
* @param configuration the configuration
* @param path the path
+ * @param defaultValue the default value
+ * @param comment the comment to add to the field
*/
- public ConfigField(FileConfiguration configuration, String path){
- this.config = configuration;
- this.path = path;
+ public ConfigField(YMLConfig configuration, String path, Object defaultValue, String comment){
+ this(configuration, path, defaultValue, comment, CommentType.BLOCK);
}
- private void add() {
- if(!this.config.contains(this.path)) this.config.set(this.path, this.def);
+ /**
+ * Constructor of the ConfigField. If the specified path doesn't exists or is empty, it will be filled with the default value
+ * @param configuration the configuration
+ * @param path the path
+ * @param defaultValue the default value
+ */
+ public ConfigField(YMLConfig configuration, String path, Object defaultValue){
+ this(configuration, path, defaultValue, null);
+ }
+
+ /**
+ * Constructor of the ConfigField (Without default value)
+ * @param configuration the configuration
+ * @param path the path
+ */
+ public ConfigField(YMLConfig configuration, String path){
+ this(configuration, path, null, null);
}
/**
@@ -111,7 +135,7 @@ public List asStringList(){
* @return the value of the path as a Section
*/
public ConfigurationSection asSection(){
- return this.config.getConfigurationSection(this.path);
+ return this.config.getSection(this.path);
}
/**
@@ -128,10 +152,10 @@ public Set asKeys(boolean deep){
}
/**
- * Gets the File Configuration
- * @return the file configuration
+ * Gets the YMLConfiguration
+ * @return the YMLConfiguration
*/
- public FileConfiguration getConfig() {
+ public YMLConfig getConfig() {
return config;
}
diff --git a/src/main/java/xyz/theprogramsrc/supercoreapi/spigot/utils/storage/SpigotYMLConfig.java b/src/main/java/xyz/theprogramsrc/supercoreapi/global/files/yml/YMLConfig.java
similarity index 82%
rename from src/main/java/xyz/theprogramsrc/supercoreapi/spigot/utils/storage/SpigotYMLConfig.java
rename to src/main/java/xyz/theprogramsrc/supercoreapi/global/files/yml/YMLConfig.java
index fe7c9085..c5f6bb6b 100644
--- a/src/main/java/xyz/theprogramsrc/supercoreapi/spigot/utils/storage/SpigotYMLConfig.java
+++ b/src/main/java/xyz/theprogramsrc/supercoreapi/global/files/yml/YMLConfig.java
@@ -1,70 +1,106 @@
-package xyz.theprogramsrc.supercoreapi.spigot.utils.storage;
+package xyz.theprogramsrc.supercoreapi.global.files.yml;
-import org.bukkit.configuration.ConfigurationSection;
-import org.bukkit.configuration.file.FileConfiguration;
-import org.bukkit.configuration.file.YamlConfiguration;
+import org.simpleyaml.configuration.ConfigurationSection;
+import org.simpleyaml.configuration.comments.CommentType;
+import org.simpleyaml.configuration.file.FileConfiguration;
+import org.simpleyaml.configuration.file.YamlFile;
+import org.simpleyaml.exceptions.InvalidConfigurationException;
import xyz.theprogramsrc.supercoreapi.global.utils.Utils;
import java.io.File;
+import java.io.IOException;
import java.util.List;
import java.util.Set;
-/**
- * Used to generate and work with YAML files
- */
-public class SpigotYMLConfig {
- private FileConfiguration config;
+public class YMLConfig {
+
+ private final YamlFile config;
private final File file;
- public SpigotYMLConfig(File file){
+ public YMLConfig(File file){
this.file = file;
+ this.config = new YamlFile(file);
this.load();
}
- public SpigotYMLConfig(File folder, String fileName){
- this(new File(Utils.folder(folder), fileName));
+ public YMLConfig(File folder, String name){
+ this(new File(Utils.folder(folder), name));
}
- private void load(){
- try {
+ /**
+ * Loads the configuration from the file into the memory overriding any existing changes.
+ */
+ public void load(){
+ try{
if(!this.file.exists()) this.file.createNewFile();
- this.config = YamlConfiguration.loadConfiguration(this.file);
- }catch (Exception ex){
- ex.printStackTrace();
+ this.config.load(this.file);
+ }catch (IOException | InvalidConfigurationException e){
+ e.printStackTrace();
}
}
/**
- * Clear the file and his contents
- * and then create a new file
+ * Saves the configuration to the file
+ */
+ public void save(){
+ try{
+ this.config.save(this.file);
+ }catch (IOException e){
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Clear the file and its content and then create a new file
*/
public void clear(){
try{
Utils.destroyFile(this.file);
if(!this.file.exists())this.file.createNewFile();
- this.reload();
+ this.load();
}catch (Exception ex){
ex.printStackTrace();
}
}
/**
- * Used to reload the cache
- * (Make sure to use {@link #save()} before executing this)
+ * Sets a comment into the given path using the given content and type replacing the existing one
+ * @param path the path where the comment
+ * @param comment the comment to add
+ * @param commentType the type of comment to add
+ */
+ public void setComment(String path, String comment, CommentType commentType){
+ this.config.setComment(path, comment, commentType);
+ this.save();
+ }
+
+ /**
+ * Sets a comment into the given path using the given content replacing the existing one
+ * @param path the path where the comment
+ * @param comment the comment to add
*/
- public void reload(){
- this.config = YamlConfiguration.loadConfiguration(this.file);
+ public void setComment(String path, String comment){
+ this.config.setComment(path, comment);
+ this.save();
}
/**
- * Used to save all the cached information
+ * Adds a comment into the given path using the given content and type
+ * @param path the path where the comment
+ * @param comment the comment to add
+ * @param commentType the type of comment to add
*/
- public void save(){
- try{
- this.config.save(this.file);
- }catch (Exception ex){
- ex.printStackTrace();
- }
+ public void addComment(String path, String comment, CommentType commentType){
+ if(this.config.getComment(path, commentType) == null) this.config.setComment(path, comment, commentType);
+ }
+
+ /**
+ * Adds a comment into the given path using the given content replacing the existing one
+ * @param path the path where the comment
+ * @param comment the comment to add
+ */
+ public void addComment(String path, String comment){
+ if(this.config.getComment(path) == null) this.config.setComment(path, comment);
}
/**
@@ -403,8 +439,8 @@ public Set getKeys(boolean deep){
}
/**
- * Used to get the main {@link FileConfiguration}
- * @return Main {@link FileConfiguration}
+ * Used to get the {@link FileConfiguration}
+ * @return the {@link FileConfiguration}
*/
public FileConfiguration getConfig() {
return config;
diff --git a/src/main/java/xyz/theprogramsrc/supercoreapi/global/notifications/Notification.java b/src/main/java/xyz/theprogramsrc/supercoreapi/global/notifications/Notification.java
deleted file mode 100644
index 4c21e1d2..00000000
--- a/src/main/java/xyz/theprogramsrc/supercoreapi/global/notifications/Notification.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package xyz.theprogramsrc.supercoreapi.global.notifications;
-
-import com.google.gson.JsonObject;
-
-public class Notification {
-
- private final String title, content;
- private final long createdAt;
-
- public Notification(String title, String content) {
- this.title = title;
- this.content = content;
- this.createdAt = System.currentTimeMillis();
- }
-
- public Notification(String title, String content, long createdAt) {
- this.title = title;
- this.content = content;
- this.createdAt = createdAt;
- }
-
- public String getTitle() {
- return title;
- }
-
- public String getContent() {
- return content;
- }
-
- public long getCreatedAt() {
- return createdAt;
- }
-
- @Override
- public String toString() {
- JsonObject json = new JsonObject();
- json.addProperty("title", this.getTitle());
- json.addProperty("content", this.getContent());
- return json.toString();
- }
-
- public static NotificationBuilder builder(){
- return new NotificationBuilder();
- }
-
- public static class NotificationBuilder{
- private String title, content;
- private long createdAt;
-
- public NotificationBuilder setTitle(String title) {
- this.title = title;
- return this;
- }
-
- public NotificationBuilder setContent(String content) {
- this.content = content;
- return this;
- }
-
- public NotificationBuilder setCreatedAt(long createdAt) {
- this.createdAt = createdAt;
- return this;
- }
-
- public Notification build(){
- return new Notification(this.title, this.content, this.createdAt);
- }
- }
-}
diff --git a/src/main/java/xyz/theprogramsrc/supercoreapi/global/notifications/NotificationCollection.java b/src/main/java/xyz/theprogramsrc/supercoreapi/global/notifications/NotificationCollection.java
deleted file mode 100644
index d918f308..00000000
--- a/src/main/java/xyz/theprogramsrc/supercoreapi/global/notifications/NotificationCollection.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package xyz.theprogramsrc.supercoreapi.global.notifications;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.function.Consumer;
-
-public class NotificationCollection {
-
- private final List notifications;
-
- public NotificationCollection(List notifications){
- this.notifications = notifications;
- }
-
- public void forEach(Consumer notificationConsumer){
- this.notifications.forEach(notificationConsumer);
- }
-
- public Notification getLatest(){
- HashMap nots = new HashMap<>();
- List times = new ArrayList<>();
- notifications.forEach(n->{
- long createdAt = n.getCreatedAt();
- nots.put(createdAt, n);
- times.add(createdAt);
- });
- if(nots.size() == 0 || times.size() == 0){
- return null;
- }
-
- long newest = Collections.min(times);
- return nots.get(newest);
- }
-
- public Notification get(int index){
- return this.notifications.get(index);
- }
-
- public Notification[] get(){
- Notification[] notifications = new Notification[this.notifications.size()];
- notifications = this.notifications.toArray(notifications);
- return notifications;
- }
-}
diff --git a/src/main/java/xyz/theprogramsrc/supercoreapi/global/storage/universal/UniversalStorage.java b/src/main/java/xyz/theprogramsrc/supercoreapi/global/storage/universal/UniversalStorage.java
index ca86ce09..d5d859a5 100644
--- a/src/main/java/xyz/theprogramsrc/supercoreapi/global/storage/universal/UniversalStorage.java
+++ b/src/main/java/xyz/theprogramsrc/supercoreapi/global/storage/universal/UniversalStorage.java
@@ -4,12 +4,12 @@
import com.google.gson.JsonPrimitive;
import xyz.theprogramsrc.supercoreapi.SuperPlugin;
import xyz.theprogramsrc.supercoreapi.global.files.JsonConfig;
-import xyz.theprogramsrc.supercoreapi.global.json.JSONUtil;
import xyz.theprogramsrc.supercoreapi.global.storage.DataBase;
import xyz.theprogramsrc.supercoreapi.global.storage.DataBaseSettings;
import xyz.theprogramsrc.supercoreapi.global.storage.MySQLDataBase;
import xyz.theprogramsrc.supercoreapi.global.storage.SQLiteDataBase;
import xyz.theprogramsrc.supercoreapi.global.utils.Utils;
+import xyz.theprogramsrc.supercoreapi.global.utils.json.JSONUtil;
import java.io.File;
diff --git a/src/main/java/xyz/theprogramsrc/supercoreapi/global/translations/Base.java b/src/main/java/xyz/theprogramsrc/supercoreapi/global/translations/Base.java
index 2ef6a4e7..3fa10594 100644
--- a/src/main/java/xyz/theprogramsrc/supercoreapi/global/translations/Base.java
+++ b/src/main/java/xyz/theprogramsrc/supercoreapi/global/translations/Base.java
@@ -2,114 +2,116 @@
import java.util.Arrays;
import java.util.List;
-import java.util.Locale;
import java.util.stream.Collectors;
public enum Base implements TranslationPack{
- OK("Ok"),
- ADD("Add"),
- REMOVE("Remove"),
- DONE("Done"),
- COMPLETED("Completed"),
- CANCEL("Cancel"),
- LEFT_CLICK("Left Click"),
- SHIFT_CLICK("Shift Click"),
- MIDDLE_CLICK("Middle Click"),
- RIGHT_CLICK("Right Click"),
- LANGUAGES("Languages"),
- SELECT("Select"),
- SETTINGS("Settings"),
- ENABLED("Enabled"),
- DISABLED("Disabled"),
- PLAYER("Player"),
- PLAYERS("Players"),
- CONSOLE("Console"),
- CONFIRM("Confirm"),
- DECLINE("Decline"),
- GENERAL("General"),
+ DISPLAY("Display", "English"),
+ OK("General.Ok","Ok"),
+ ADD("General.Add","Add"),
+ REMOVE("General.Remove","Remove"),
+ DONE("General.Done","Done"),
+ COMPLETED("General.Completed","Completed"),
+ CANCEL("General.Cancel","Cancel"),
+ LEFT_CLICK("General.LeftClick","Left Click"),
+ SHIFT_CLICK("General.ShiftClick","Shift Click"),
+ MIDDLE_CLICK("General.MiddleClick","Middle Click"),
+ RIGHT_CLICK("General.RightClick","Right Click"),
+ LANGUAGES("General.Languages","Languages"),
+ SELECT("General.Select","Select"),
+ SETTINGS("General.Settings","Settings"),
+ ENABLED("General.Enabled","Enabled"),
+ DISABLED("General.Disabled","Disabled"),
+ PLAYER("General.Player","Player"),
+ PLAYERS("General.Players","Players"),
+ CONSOLE("General.Console","Console"),
+ CONFIRM("General.Confirm","Confirm"),
+ DECLINE("General.Decline","Decline"),
+ GENERAL("General.General","General"),
/* MESSAGES */
- NO_PERMISSION("&cYou dont have permission."),
- NO_ACCESS("&cYou dont have access!"),
- NOT_SUPPORTED("&cThis command it's only for &e{Supported}"),
- INVALID_ARGUMENTS("&cInvalid Arguments!"),
+ NO_PERMISSION("Commands.NoPermission","&cYou dont have permission."),
+ NO_ACCESS("Commands.NoAccess","&cYou dont have access!"),
+ NOT_SUPPORTED("Commands.NotSupported","&cThis command it's only for &e{Supported}"),
+ INVALID_ARGUMENTS("Commands.InvalidArguments","&cInvalid Arguments!"),
- DIALOG_HOW_TO_CLOSE("&7Use &aLeft Click &7to close the dialog."),
- DIALOG_CLOSED("&7You &cclosed &7this dialog."),
+ DIALOG_HOW_TO_CLOSE("Dialog.HowToClose","&7Use &aLeft Click &7to close the dialog."),
+ DIALOG_CLOSED("Dialog.Closed","&7You &cclosed &7this dialog."),
/* DIALOGS */
- DIALOG_SEARCH_TITLE("&9Search"),
- DIALOG_SEARCH_SUBTITLE("&7Write a search term"),
- DIALOG_SEARCH_ACTIONBAR("&aWrite in the chat a search term to find a object"),
+ DIALOG_SEARCH_TITLE("Dialog.Search.Title","&9Search"),
+ DIALOG_SEARCH_SUBTITLE("Dialog.Search.Subtitle","&7Write a search term"),
+ DIALOG_SEARCH_ACTIONBAR("Dialog.Search.Actionbar", "&aWrite in the chat a search term to find a object"),
- DIALOG_CHANGE_PREFIX_TITLE("&9Prefix"),
- DIALOG_CHANGE_PREFIX_SUBTITLE("&7Write a new prefix"),
- DIALOG_CHANGE_PREFIX_ACTIONBAR("&aCurrent prefix: &r{Prefix}"),
+ DIALOG_CHANGE_PREFIX_TITLE("Dialog.ChangePrefix.Title", "&9Prefix"),
+ DIALOG_CHANGE_PREFIX_SUBTITLE("Dialog.ChangePrefix.Subtitle","&7Write a new prefix"),
+ DIALOG_CHANGE_PREFIX_ACTIONBAR("Dialog.ChangePrefix.Actionbar","&aCurrent prefix: &r{Prefix}"),
/* GUIs */
- SETTINGS_GUI_TITLE("&cSettings"),
- SETTING_PANE_GUI_TITLE("&cSettings &8> &9{Setting}"),
+ SETTINGS_GUI_TITLE("GUI.Settings.Title","&cSettings"),
+ SETTING_PANE_GUI_TITLE("GUI.Settings.PaneTitle","&cSettings &8> &9{Setting}"),
- SETTINGS_EDITOR_NAME("&aSettings Editor"),
- SETTINGS_EDITOR_DESCRIPTION("&7Click to edit some settings"),
+ SETTINGS_EDITOR_NAME("GUI.Settings.Items.Editor.Name","&aSettings Editor"),
+ SETTINGS_EDITOR_DESCRIPTION("GUI.Settings.Items.Editor.Lore","&7Click to edit some settings"),
- SETTINGS_GENERAL_NAME("&aGeneral Settings"),
- SETTINGS_GENERAL_DESCRIPTION("&7Click to edit general settings"),
+ SETTINGS_GENERAL_NAME("GUI.Settings.Items.General.Name", "&aGeneral Settings"),
+ SETTINGS_GENERAL_DESCRIPTION("GUI.Settings.Items.General.Lore","&7Click to edit general settings"),
- LANGUAGE_SELECTOR_NAME("&aLanguages"),
- LANGUAGE_SELECTOR_DESCRIPTION("&7Click to select a new Language."),
+ LANGUAGE_SELECTOR_NAME("GUI.Settings.Items.Languages.Name", "&aLanguages"),
+ LANGUAGE_SELECTOR_DESCRIPTION("GUI.Settings.Items.Languages.Lore","&7Click to select a new Language."),
- GENERAL_SET_PREFIX_NAME("&aSet Prefix"),
- GENERAL_SET_PREFIX_DESCRIPTION("&7Current Prefix: &r{Prefix}"),
+ GENERAL_SET_PREFIX_NAME("GUI.GeneralSettings.Items.Prefix.Name","&aSet Prefix"),
+ GENERAL_SET_PREFIX_DESCRIPTION("GUI.GeneralSettings.Items.Prefix.Lore","&7Current Prefix: &r{Prefix}"),
- GENERAL_TOGGLE_TRANSLATION_DOWNLOADER_NAME("&aToggle Translation Downloader"),
- GENERAL_TOGGLE_TRANSLATION_DOWNLOADER_DESCRIPTION("&7Current Status: &9{Status}"),
+ GENERAL_TOGGLE_TRANSLATION_DOWNLOADER_NAME("GUI.GeneralSettings.Items.TranslationDownloader.Name","&aToggle Translation Downloader"),
+ GENERAL_TOGGLE_TRANSLATION_DOWNLOADER_DESCRIPTION("GUI.GeneralSettings.Items.TranslationDownloader.Lore","&7Current Status: &9{Status}"),
- LANGUAGE_SELECT_DESCRIPTION("&7Click to select&a {Language}&7 as the current language."),
- LANGUAGE_SELECTED_DESCRIPTION("&a{Language}&7 is selected as the current language."),
+ SETTINGS_TOGGLE_UPDATER_NAME("GUI.GeneralSettings.Items.ToggleUpdater.Name","&aToggle Updater"),
+ SETTINGS_TOGGLE_UPDATER_DESCRIPTION("GUI.GeneralSettings.Items.ToggleUpdater.Lore","&7Current Status: &9{Status}"),
- SETTINGS_TOGGLE_UPDATER_NAME("&aToggle Updater"),
- SETTINGS_TOGGLE_UPDATER_DESCRIPTION("&7Current Status: &9{Status}"),
+ SETTINGS_TOGGLE_SQL_NAME("GUI.GeneralSettings.Items.ToggleSQL.Name","&aToggle SQL"),
+ SETTINGS_TOGGLE_SQL_DESCRIPTION("GUI.GeneralSettings.Items.ToggleSQL.Lore","&7Current Status: &9{Status}"),
- SETTINGS_TOGGLE_SQL_NAME("&aToggle SQL"),
- SETTINGS_TOGGLE_SQL_DESCRIPTION("&7Current Status: &9{Status}"),
+ LANGUAGE_SELECT_DESCRIPTION("GUI.Languages.Items.Name","&7Click to select&a {Language}&7 as the current language."),
+ LANGUAGE_SELECTED_DESCRIPTION("GUI.Languages.Items.Lore","&a{Language}&7 is selected as the current language."),
- MATERIAL_SELECTOR_TITLE("&7Select a Material"),
- MATERIAL_SELECTOR_ITEM_NAME("&a{Material}"),
- MATERIAL_SELECTOR_ITEM_DESCRIPTION("&7Click to select &a{Material}"),
+ MATERIAL_SELECTOR_TITLE("GUI.MaterialSelector.Title","&7Select a Material"),
+ MATERIAL_SELECTOR_ITEM_NAME("GUI.MaterialSelector.Item.Name","&a{Material}"),
+ MATERIAL_SELECTOR_ITEM_DESCRIPTION("GUI.MaterialSelector.Item.Lore","&7Click to select &a{Material}"),
/* Items */
- ITEM_BACK_NAME("&aBack"),
- ITEM_BACK_DESCRIPTION("&7Click to go Back."),
+ ITEM_BACK_NAME("Items.Back.Name","&aBack"),
+ ITEM_BACK_DESCRIPTION("Items.Back.Lore","&7Click to go Back."),
- ITEM_NEXT_NAME("&aNext"),
- ITEM_NEXT_DESCRIPTION("&7Click to go to the next page."),
+ ITEM_NEXT_NAME("Items.Next.Name","&aNext"),
+ ITEM_NEXT_DESCRIPTION("Items.Next.Lore","&7Click to go to the next page."),
- ITEM_PREVIOUS_NAME("&aPrevious"),
- ITEM_PREVIOUS_DESCRIPTION("&7Click to go to the previous page."),
+ ITEM_PREVIOUS_NAME("Items.Previous.Name","&aPrevious"),
+ ITEM_PREVIOUS_DESCRIPTION("Items.Previous.Lore","&7Click to go to the previous page."),
- ITEM_SEARCH_NAME("&aSearch"),
- ITEM_SEARCH_DESCRIPTION("&7Click to search between objects."),
+ ITEM_SEARCH_NAME("Items.Search.Name","&aSearch"),
+ ITEM_SEARCH_DESCRIPTION("Items.Search.Name","&7Click to search between objects."),
- ITEM_END_SEARCH_NAME("&aEnd Search"),
- ITEM_END_SEARCH_DESCRIPTION("&7Click to end with the search"),
+ ITEM_END_SEARCH_NAME("Items.EndSearch.Name","&aEnd Search"),
+ ITEM_END_SEARCH_DESCRIPTION("Items.EndSearch.Name","&7Click to end with the search"),
;
+ private final String path;
private final String content;
private TranslationManager manager;
- Base(String content){
+ Base(String path, String content){
this.content = content;
+ this.path = path;
}
@Override
- public Locale getLanguage() {
- return new Locale("en","US");
+ public String getLanguage() {
+ return "en";
}
@Override
public Translation get() {
- return new Translation(this, this.name(), this.content);
+ return new Translation(this, this.path, this.content);
}
@Override
diff --git a/src/main/java/xyz/theprogramsrc/supercoreapi/global/translations/Translation.java b/src/main/java/xyz/theprogramsrc/supercoreapi/global/translations/Translation.java
index 409e45d1..e22a8591 100644
--- a/src/main/java/xyz/theprogramsrc/supercoreapi/global/translations/Translation.java
+++ b/src/main/java/xyz/theprogramsrc/supercoreapi/global/translations/Translation.java
@@ -8,11 +8,11 @@
public class Translation {
private final TranslationPack pack;
- private final String id, value;
+ private final String path, value;
- public Translation(TranslationPack pack, String id, String value) {
+ public Translation(TranslationPack pack, String path, String value) {
this.pack = pack;
- this.id = id;
+ this.path = path;
this.value = value;
}
@@ -20,8 +20,8 @@ public TranslationPack getPack() {
return pack;
}
- public String getId() {
- return id;
+ public String getPath() {
+ return path;
}
public String getValue() {
@@ -29,10 +29,10 @@ public String getValue() {
}
public String translate(){
- return this.pack.getManager().translate(this.id);
+ return this.pack.getManager().translate(this.path);
}
public StringUtils options(){
return new StringUtils(this.translate());
}
-}
+}
\ No newline at end of file
diff --git a/src/main/java/xyz/theprogramsrc/supercoreapi/global/translations/TranslationDownloader.java b/src/main/java/xyz/theprogramsrc/supercoreapi/global/translations/TranslationDownloader.java
index 48210afc..504d07b0 100644
--- a/src/main/java/xyz/theprogramsrc/supercoreapi/global/translations/TranslationDownloader.java
+++ b/src/main/java/xyz/theprogramsrc/supercoreapi/global/translations/TranslationDownloader.java
@@ -5,8 +5,8 @@
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import xyz.theprogramsrc.supercoreapi.SuperPlugin;
-import xyz.theprogramsrc.supercoreapi.global.utils.FileUtils;
import xyz.theprogramsrc.supercoreapi.global.utils.Utils;
+import xyz.theprogramsrc.supercoreapi.global.utils.files.FileUtils;
import java.io.File;
@@ -41,7 +41,7 @@ public static void downloadFromGitHub(final SuperPlugin> core, final String us
}
}
}
- core.getTranslationManager().reloadTranslations();
+ core.getTranslationManager().loadTranslations();
}catch (Exception ex){
ex.printStackTrace();
}
diff --git a/src/main/java/xyz/theprogramsrc/supercoreapi/global/translations/TranslationManager.java b/src/main/java/xyz/theprogramsrc/supercoreapi/global/translations/TranslationManager.java
index fae0c809..29b2ff58 100644
--- a/src/main/java/xyz/theprogramsrc/supercoreapi/global/translations/TranslationManager.java
+++ b/src/main/java/xyz/theprogramsrc/supercoreapi/global/translations/TranslationManager.java
@@ -2,21 +2,26 @@
import sun.misc.Unsafe;
import xyz.theprogramsrc.supercoreapi.SuperPlugin;
+import xyz.theprogramsrc.supercoreapi.global.files.yml.YMLConfig;
import xyz.theprogramsrc.supercoreapi.global.utils.Utils;
import java.io.File;
import java.lang.reflect.Field;
-import java.util.*;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Set;
public class TranslationManager {
- private LinkedHashMap> translations;
protected SuperPlugin> plugin;
+ private final File langFolder;
+ private final LinkedHashMap> CACHE;
public TranslationManager(SuperPlugin> plugin) {
this.plugin = plugin;
- this.translations = new LinkedHashMap<>();
- this.reloadTranslations();
+ this.langFolder = Utils.folder(new File(this.plugin.getPluginFolder(), "lang/"));
+ CACHE = new LinkedHashMap<>();
+ this.loadTranslations();
}
/**
@@ -27,32 +32,23 @@ public TranslationManager(SuperPlugin> plugin) {
public void registerTranslation(Class extends TranslationPack> clazz){
this.plugin.debug("Registering translation '" + clazz.getName() + "'");
try{
+ // Here we initialize the class
Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
theUnsafe.setAccessible(true);
Unsafe unsafe = ((Unsafe)theUnsafe.get(null));
TranslationPack pack = ((TranslationPack)unsafe.allocateInstance(clazz));
- List translations = pack.translations();
- translations.forEach(t-> t.getPack().setManager(this));
- File file = new File(this.plugin.getTranslationsFolder(), pack.getLanguage().toString() + ".lang");
- final LinkedHashMap translationsMap = new LinkedHashMap<>();
- if(file.exists()){
- Utils.readLines(file).stream().filter(l-> !l.startsWith("#") && l.contains("=")).forEach(l->{
- String[] data = l.split("=",2);
- String key = data[0];
- String value = data[1];
- translationsMap.put(key,value);
- });
- file.delete();
+
+ // Now we setup the manager for every translation
+ List defaultTranslations = pack.translations();
+ defaultTranslations.forEach(t-> t.getPack().setManager(this));
+
+ // Now we load the save translations without replacing existing ones (to allow customization)
+ YMLConfig lang = new YMLConfig(this.langFolder, pack.getLanguage() + ".yml");
+ for(Translation translation : defaultTranslations){
+ translation.getPack().setManager(this);
+ lang.add(translation.getPath(), translation.getValue());
}
- translations.forEach(t-> translationsMap.put(t.getId(), t.getValue()));
- file.createNewFile();
- String[] comments = {"# Default translation " + pack.getLanguage().toString(),"# If you want to edit the translations copy this file and rename it", "# The file name format is 'language_COUNTRY.lang'","# Also you can search about Java Locales", "#", "# If you're translating this file, remember to not translate placeholders nor keys!"};
- String[] translationsArray = translationsMap.entrySet().stream().map(e-> e.getKey() + "=" + e.getValue()).toArray(String[]::new);
- List lines = new ArrayList<>();
- lines.addAll(Utils.toList(comments));
- lines.addAll(Utils.toList(translationsArray));
- Utils.writeFile(file, lines);
- this.reloadTranslations();
+ this.loadTranslations();
}catch (Exception ex){
ex.printStackTrace();
}
@@ -61,33 +57,21 @@ public void registerTranslation(Class extends TranslationPack> clazz){
/**
* Clear the caches and load all the available translations
*/
- public void reloadTranslations(){
+ public void loadTranslations(){
this.plugin.debug("Reloading translations");
- if(this.translations == null) this.translations = new LinkedHashMap<>();
- this.translations.clear();
- File[] translationsFiles = this.plugin.getTranslationsFolder().listFiles();
- if(translationsFiles != null){
- if(translationsFiles.length != 0){
- for(File file : translationsFiles){
- if(file.getName().endsWith(".lang") && file.getName().contains("_")){
- String name = file.getName().replace(".lang", "");
- String lang = name.split("_")[0];
- String country = name.split("_")[1];
- Locale locale = new Locale(lang, country);
- LinkedHashMap translations = this.translations.getOrDefault(locale, new LinkedHashMap<>());
- try{
- List lines = Utils.readLines(file);
- lines.stream().filter(l-> !l.startsWith("#") && l.contains("=")).forEach(l->{
- String[] data = l.split("=",2);
- String key = data[0];
- String value = data[1];
- translations.put(key,value);
- });
- }catch (Exception ex){
- ex.printStackTrace();
- }
- this.translations.put(locale, translations);
+ this.CACHE.clear(); // We clear the cache
+ File[] files = this.langFolder.listFiles();
+ if(files != null && files.length != 0){
+ for(File file : files){ // Now we list all the files and filter by only the .yml files
+ if(file.getName().endsWith(".yml")){
+ String lang = file.getName().replace(".yml", ""); // Now we parse the language
+ YMLConfig cfg = new YMLConfig(file); // Generate the Config
+ LinkedHashMap translations = new LinkedHashMap<>(); // Generate the translations
+ Set keys = cfg.getKeys(true); // Retrieve the IDs
+ for(String key : keys){
+ translations.put(key, cfg.getString(key, "")); // Retrieve and save the key and value
}
+ this.CACHE.put(lang, translations); // Save to cache
}
}
}
@@ -109,24 +93,20 @@ public String translate(String id) {
* @return Translated identifier
*/
public String translate(String id, String def){
- String currentLanguage = this.plugin.getLanguage();
- Locale locale = new Locale(currentLanguage.split("_")[0], currentLanguage.split("_")[1]);
- if(!this.translations.containsKey(locale)){
- if(!locale.equals(new Locale("en", "US"))){
- return this.translations.get(new Locale("en","US")).getOrDefault(id, def);
- }else{
- return def;
- }
- }else{
- return this.translations.get(locale).getOrDefault(id, def);
+ String currentLang = this.plugin.getLanguage();
+ if(!this.CACHE.containsKey(currentLang)){
+ currentLang = "en";
}
+
+ LinkedHashMap translations = this.CACHE.get(currentLang);
+ return translations.getOrDefault(id, def);
}
/**
* Gets the available translations
* @return the available translations
*/
- public Locale[] getTranslations() {
- return this.translations.keySet().toArray(new Locale[0]);
+ public String[] getTranslations() {
+ return this.CACHE.keySet().toArray(new String[0]);
}
}
diff --git a/src/main/java/xyz/theprogramsrc/supercoreapi/global/translations/TranslationPack.java b/src/main/java/xyz/theprogramsrc/supercoreapi/global/translations/TranslationPack.java
index c7daad4e..49d5fb76 100644
--- a/src/main/java/xyz/theprogramsrc/supercoreapi/global/translations/TranslationPack.java
+++ b/src/main/java/xyz/theprogramsrc/supercoreapi/global/translations/TranslationPack.java
@@ -3,7 +3,6 @@
import xyz.theprogramsrc.supercoreapi.global.utils.StringUtils;
import java.util.List;
-import java.util.Locale;
/**
* This util is designed for the Enum class
@@ -14,7 +13,7 @@ public interface TranslationPack {
* Gets the language of the file
* @return Language locale of the file
*/
- Locale getLanguage();
+ String getLanguage();
/**
* Gets a single translation
@@ -47,17 +46,4 @@ public interface TranslationPack {
default StringUtils options(){
return this.get().options();
}
-
- /**
- *
- * This will return the language display name in his own language
- *
- * If the language is es_ES it will return "Español",
- * if the language is en_US it will return "English"
- *
- * @return The name of the language
- */
- default String getDisplayLanguage(){
- return this.getLanguage().getDisplayLanguage(this.getLanguage());
- }
}
diff --git a/src/main/java/xyz/theprogramsrc/supercoreapi/global/utils/Utils.java b/src/main/java/xyz/theprogramsrc/supercoreapi/global/utils/Utils.java
index 9f710889..ab05f34a 100644
--- a/src/main/java/xyz/theprogramsrc/supercoreapi/global/utils/Utils.java
+++ b/src/main/java/xyz/theprogramsrc/supercoreapi/global/utils/Utils.java
@@ -548,7 +548,7 @@ public static T[] addToArray(T[] originalArray, T objectToAdd) {
* @return Folder checked
*/
public static File folder(File folder) {
- if(!folder.exists()) folder.mkdir();
+ if(!folder.exists()) folder.mkdirs();
return folder;
}
diff --git a/src/main/java/xyz/theprogramsrc/supercoreapi/global/utils/FileUtils.java b/src/main/java/xyz/theprogramsrc/supercoreapi/global/utils/files/FileUtils.java
similarity index 98%
rename from src/main/java/xyz/theprogramsrc/supercoreapi/global/utils/FileUtils.java
rename to src/main/java/xyz/theprogramsrc/supercoreapi/global/utils/files/FileUtils.java
index 9d1c2a20..60b191e5 100644
--- a/src/main/java/xyz/theprogramsrc/supercoreapi/global/utils/FileUtils.java
+++ b/src/main/java/xyz/theprogramsrc/supercoreapi/global/utils/files/FileUtils.java
@@ -1,4 +1,4 @@
-package xyz.theprogramsrc.supercoreapi.global.utils;
+package xyz.theprogramsrc.supercoreapi.global.utils.files;
import java.io.BufferedInputStream;
import java.io.File;
diff --git a/src/main/java/xyz/theprogramsrc/supercoreapi/global/files/utils/ZipUtils.java b/src/main/java/xyz/theprogramsrc/supercoreapi/global/utils/files/ZipUtils.java
similarity index 98%
rename from src/main/java/xyz/theprogramsrc/supercoreapi/global/files/utils/ZipUtils.java
rename to src/main/java/xyz/theprogramsrc/supercoreapi/global/utils/files/ZipUtils.java
index 9f672114..eec225c2 100644
--- a/src/main/java/xyz/theprogramsrc/supercoreapi/global/files/utils/ZipUtils.java
+++ b/src/main/java/xyz/theprogramsrc/supercoreapi/global/utils/files/ZipUtils.java
@@ -1,4 +1,4 @@
-package xyz.theprogramsrc.supercoreapi.global.files.utils;
+package xyz.theprogramsrc.supercoreapi.global.utils.files;
import java.io.File;
import java.io.FileInputStream;
diff --git a/src/main/java/xyz/theprogramsrc/supercoreapi/global/json/JSONUtil.java b/src/main/java/xyz/theprogramsrc/supercoreapi/global/utils/json/JSONUtil.java
similarity index 99%
rename from src/main/java/xyz/theprogramsrc/supercoreapi/global/json/JSONUtil.java
rename to src/main/java/xyz/theprogramsrc/supercoreapi/global/utils/json/JSONUtil.java
index b4138024..16925a4e 100644
--- a/src/main/java/xyz/theprogramsrc/supercoreapi/global/json/JSONUtil.java
+++ b/src/main/java/xyz/theprogramsrc/supercoreapi/global/utils/json/JSONUtil.java
@@ -1,4 +1,4 @@
-package xyz.theprogramsrc.supercoreapi.global.json;
+package xyz.theprogramsrc.supercoreapi.global.utils.json;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
diff --git a/src/main/java/xyz/theprogramsrc/supercoreapi/spigot/SpigotPlugin.java b/src/main/java/xyz/theprogramsrc/supercoreapi/spigot/SpigotPlugin.java
index 7ad132ca..12642d6b 100644
--- a/src/main/java/xyz/theprogramsrc/supercoreapi/spigot/SpigotPlugin.java
+++ b/src/main/java/xyz/theprogramsrc/supercoreapi/spigot/SpigotPlugin.java
@@ -82,7 +82,7 @@ public void onEnable() {
this.debug("Loading SettingsStorage");
this.settingsStorage = new SettingsStorage();
this.debug("Loading Translations");
- this.translationsFolder = Utils.folder(new File(this.getDataFolder(), "translations/"));
+ this.translationsFolder = Utils.folder(new File(this.getDataFolder(), "lang/"));
this.translationManager = new TranslationManager(this);
this.getTranslationManager().registerTranslation(Base.class);
this.debug("Loading SkinManager");
diff --git a/src/main/java/xyz/theprogramsrc/supercoreapi/spigot/commands/precreated/SuperCoreAPICommand.java b/src/main/java/xyz/theprogramsrc/supercoreapi/spigot/commands/precreated/SuperCoreAPICommand.java
index ea3e4025..37cfcddf 100644
--- a/src/main/java/xyz/theprogramsrc/supercoreapi/spigot/commands/precreated/SuperCoreAPICommand.java
+++ b/src/main/java/xyz/theprogramsrc/supercoreapi/spigot/commands/precreated/SuperCoreAPICommand.java
@@ -18,12 +18,14 @@ public abstract class SuperCoreAPICommand extends SpigotCommand {
protected void executeInfoCommand(CommandSender sender){
Field tpsField = null;
Object minecraftServer = null;
- try {
- minecraftServer = ReflectionUtils.getNMSClass("MinecraftServer").getMethod("getServer").invoke(null);
- tpsField = minecraftServer.getClass().getField("recentTps");
- } catch (NoSuchFieldException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException e) {
- this.plugin.addError(e);
- e.printStackTrace();
+ if(Utils.hasClass(ReflectionUtils.NMS + "MinecraftServer")){
+ try {
+ minecraftServer = ReflectionUtils.getNMSClass("MinecraftServer").getMethod("getServer").invoke(null);
+ tpsField = minecraftServer.getClass().getField("recentTps");
+ } catch (NoSuchFieldException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException e) {
+ this.plugin.addError(e);
+ e.printStackTrace();
+ }
}
@@ -45,11 +47,11 @@ protected void executeInfoCommand(CommandSender sender){
this.getSuperUtils().sendMessage(sender, "&7Last Errors: &9" + lastErrors);
if(tpsField != null){
try{
- double[] tps = ((double[]) tpsField.get(minecraftServer));
+ double[] tpsData = ((double[]) tpsField.get(minecraftServer));
this.getSuperUtils().sendMessage(sender, "&6TPS from last 1m, 5m, 15m: &a"
- + format.format(tps[0]) + ", "
- + format.format(tps[1]) + ", "
- + format.format(tps[2])
+ + format.format(tpsData[0]) + ", "
+ + format.format(tpsData[1]) + ", "
+ + format.format(tpsData[2])
);
}catch (IllegalAccessException e){
this.plugin.addError(e);
diff --git a/src/main/java/xyz/theprogramsrc/supercoreapi/spigot/guis/precreated/settings/precreated/LanguageSelectionSettingPane.java b/src/main/java/xyz/theprogramsrc/supercoreapi/spigot/guis/precreated/settings/precreated/LanguageSelectionSettingPane.java
index 9a056c6f..71b14520 100644
--- a/src/main/java/xyz/theprogramsrc/supercoreapi/spigot/guis/precreated/settings/precreated/LanguageSelectionSettingPane.java
+++ b/src/main/java/xyz/theprogramsrc/supercoreapi/spigot/guis/precreated/settings/precreated/LanguageSelectionSettingPane.java
@@ -6,9 +6,7 @@
import xyz.theprogramsrc.supercoreapi.spigot.guis.precreated.settings.CustomSettingPane;
import xyz.theprogramsrc.supercoreapi.spigot.items.SimpleItem;
-import java.util.Locale;
-
-public class LanguageSelectionSettingPane extends CustomSettingPane {
+public class LanguageSelectionSettingPane extends CustomSettingPane {
@Override
public String getDisplayName() {
@@ -26,23 +24,23 @@ public SimpleItem getDisplayItem() {
}
@Override
- public GUIButton getButton(Locale locale) {
- boolean selected = this.getSettings().getLanguage().equals(locale.toString());
+ public GUIButton getButton(String language) {
+ boolean selected = this.getSettings().getLanguage().equals(language);
SimpleItem item = new SimpleItem(XMaterial.BOOK)
- .setDisplayName("&a" + locale.getDisplayLanguage())
+ .setDisplayName("&a" + this.plugin.getTranslationManager().translate("Display", language))
.setLore(
"&7",
"&7" + (selected ? Base.LANGUAGE_SELECTED_DESCRIPTION : Base.LANGUAGE_SELECT_DESCRIPTION)
- ).addPlaceholder("{Language}", locale.getDisplayLanguage(locale));
+ ).addPlaceholder("{Language}", this.plugin.getTranslationManager().translate("Display", language));
return new GUIButton(item, a->{
- this.getSettings().setLanguage(locale.toString());
- this.getSettings().getConfig().reload();
+ this.getSettings().setLanguage(language);
+ this.getSettings().getConfig().load();
a.openGUI();
});
}
@Override
- public Locale[] getObjects() {
+ public String[] getObjects() {
return this.spigotPlugin.getTranslationManager().getTranslations();
}
diff --git a/src/main/java/xyz/theprogramsrc/supercoreapi/spigot/storage/SettingsStorage.java b/src/main/java/xyz/theprogramsrc/supercoreapi/spigot/storage/SettingsStorage.java
index ba49cc8a..4c40e635 100644
--- a/src/main/java/xyz/theprogramsrc/supercoreapi/spigot/storage/SettingsStorage.java
+++ b/src/main/java/xyz/theprogramsrc/supercoreapi/spigot/storage/SettingsStorage.java
@@ -1,19 +1,19 @@
package xyz.theprogramsrc.supercoreapi.spigot.storage;
+import xyz.theprogramsrc.supercoreapi.global.files.yml.YMLConfig;
import xyz.theprogramsrc.supercoreapi.spigot.SpigotModule;
-import xyz.theprogramsrc.supercoreapi.spigot.utils.storage.SpigotYMLConfig;
/**
* Representation of the Plugin Settings File
*/
public class SettingsStorage extends SpigotModule {
- private SpigotYMLConfig cfg;
+ private YMLConfig cfg;
private String defaultPrefix;
@Override
public void onLoad() {
- this.cfg = new SpigotYMLConfig(this.getPluginFolder(), "Settings.yml");
+ this.cfg = new YMLConfig(this.getPluginFolder(), "Settings.yml");
this.defaultPrefix = "&9" + this.getPluginName() + "»&r";
if(this.plugin.isFirstStart()){
this.loadDefaults();
@@ -54,14 +54,14 @@ public String getLanguage() {
private void loadDefaults(){
this.cfg.add("Prefix", this.defaultPrefix);
- this.cfg.add("Language", "en_US");
+ this.cfg.add("Language", "en");
}
/**
* Gets the Config
* @return the config
*/
- public SpigotYMLConfig getConfig() {
+ public YMLConfig getConfig() {
return cfg;
}
}
diff --git a/src/test/java/xyz/theprogramsrc/supercoreapi/global/json/JSONUtilTest.java b/src/test/java/xyz/theprogramsrc/supercoreapi/global/utils/json/JSONUtilTest.java
similarity index 95%
rename from src/test/java/xyz/theprogramsrc/supercoreapi/global/json/JSONUtilTest.java
rename to src/test/java/xyz/theprogramsrc/supercoreapi/global/utils/json/JSONUtilTest.java
index 090792ff..fd6f10f2 100644
--- a/src/test/java/xyz/theprogramsrc/supercoreapi/global/json/JSONUtilTest.java
+++ b/src/test/java/xyz/theprogramsrc/supercoreapi/global/utils/json/JSONUtilTest.java
@@ -1,4 +1,4 @@
-package xyz.theprogramsrc.supercoreapi.global.json;
+package xyz.theprogramsrc.supercoreapi.global.utils.json;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;