Adds some missing comments

This commit is contained in:
Kristian Knarvik 2021-09-09 02:24:55 +02:00
parent 852886e818
commit 245a580a43

View File

@ -297,8 +297,12 @@ public class BooksWithoutBorders extends JavaPlugin {
} }
} }
/**
* Initializes the plugin, loading and fixing the config file
* @return <p>True if successful</p>
*/
private boolean initialize() { private boolean initialize() {
//initializes Item Factory //Initialize Item Factory
try { try {
itemFactory = this.getServer().getItemFactory(); itemFactory = this.getServer().getItemFactory();
} catch (java.lang.NoSuchMethodError nsmE) { } catch (java.lang.NoSuchMethodError nsmE) {
@ -308,7 +312,7 @@ public class BooksWithoutBorders extends JavaPlugin {
return false; return false;
} }
//Pulls config values //Load config
if (!loadConfig()) { if (!loadConfig()) {
return false; return false;
} }
@ -352,6 +356,9 @@ public class BooksWithoutBorders extends JavaPlugin {
return true; return true;
} }
/**
* Saves the config
*/
public void saveConfigValues() { public void saveConfigValues() {
Configuration config = this.getConfig(); Configuration config = this.getConfig();
config.set("Options.Save_Books_in_Yaml_Format", useYml); config.set("Options.Save_Books_in_Yaml_Format", useYml);
@ -390,6 +397,10 @@ public class BooksWithoutBorders extends JavaPlugin {
this.saveConfig(); this.saveConfig();
} }
/**
* Loads the config
* @return <p>True if the config was loaded successfully</p>
*/
public boolean loadConfig() { public boolean loadConfig() {
this.reloadConfig(); this.reloadConfig();
Configuration config = this.getConfig(); Configuration config = this.getConfig();
@ -412,24 +423,24 @@ public class BooksWithoutBorders extends JavaPlugin {
welcomeMessage = config.getString("Options.Message_for_new_players", " "); welcomeMessage = config.getString("Options.Message_for_new_players", " ");
//Converts string into material //Convert string into material
String sMaterial = config.getString("Options.Price_to_create_book.Item_type", " "); String paymentMaterial = config.getString("Options.Price_to_create_book.Item_type", " ");
if (sMaterial.equalsIgnoreCase("Economy")) { if (paymentMaterial.equalsIgnoreCase("Economy")) {
if (EconomyHelper.setupEconomy()) { if (EconomyHelper.setupEconomy()) {
bookPriceType = Material.AIR; bookPriceType = Material.AIR;
} else { } else {
sendErrorMessage(consoleSender, "BooksWithoutBorders failed to hook into Vault! Book price not set!"); sendErrorMessage(consoleSender, "BooksWithoutBorders failed to hook into Vault! Book price not set!");
bookPriceType = null; bookPriceType = null;
} }
} else if (!sMaterial.equalsIgnoreCase(" ")) { } else if (!paymentMaterial.equalsIgnoreCase(" ")) {
for (Material m : Material.values()) { Material material = Material.matchMaterial(paymentMaterial);
if (m.toString().equalsIgnoreCase(sMaterial)) if (material != null) {
bookPriceType = m; bookPriceType = material;
} }
} }
bookPriceQuantity = config.getDouble("Options.Price_to_create_book.Required_quantity", 0); bookPriceQuantity = config.getDouble("Options.Price_to_create_book.Required_quantity", 0);
//makes sure titleAuthorSeparator is a valid value //Make sure titleAuthorSeparator is a valid value
titleAuthorSeparator = cleanString(titleAuthorSeparator); titleAuthorSeparator = cleanString(titleAuthorSeparator);
if (titleAuthorSeparator.length() != 1) { if (titleAuthorSeparator.length() != 1) {
sendErrorMessage(consoleSender, "Title-Author_Separator is set to an invalid value!"); sendErrorMessage(consoleSender, "Title-Author_Separator is set to an invalid value!");