Fixes some problems related to the changed economy class
This commit is contained in:
@@ -184,7 +184,7 @@ public class BooksWithoutBorders extends JavaPlugin {
|
||||
String pluginVersion = pluginDescriptionFile.getVersion();
|
||||
|
||||
Translator translator = new Translator();
|
||||
translator.registerMessageCategory(Translatable.PREFIX);
|
||||
translator.registerMessageCategory(Translatable.SUCCESS_COPY);
|
||||
stringFormatter = new StringFormatter(this.getDescription().getName(), translator);
|
||||
stringFormatter.setColorConversion(ColorConversion.RGB);
|
||||
stringFormatter.setSuccessColor(ChatColor.of("#A9FF84"));
|
||||
@@ -290,11 +290,6 @@ public class BooksWithoutBorders extends JavaPlugin {
|
||||
return false;
|
||||
}
|
||||
|
||||
//Load config
|
||||
if (!getConfiguration().loadConfig()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//Save config with loaded values to fix invalid config values
|
||||
getConfiguration().saveConfigValues();
|
||||
|
||||
|
@@ -73,7 +73,7 @@ public class CommandBooksWithoutBorders implements TabExecutor {
|
||||
} else {
|
||||
EconomyManager economyManager = BooksWithoutBorders.getConfiguration().getEconomyManager();
|
||||
if (economyManager.getEconomy() == null) {
|
||||
return BooksWithoutBorders.getStringFormatter().getUnFormattedColoredMessage(Translatable.ERROR_VAULT_COST_BUT_UNAVAILABLE);
|
||||
return BooksWithoutBorders.getStringFormatter().getUnFormattedColoredMessage(Translatable.ERROR_VAULT_COST_BUT_UNAVAILABLE) + "\n";
|
||||
} else {
|
||||
return stringFormatter.replacePlaceholder(Translatable.NEUTRAL_COMMANDS_BOOK_PRICE_ECO,
|
||||
"{price}", economyManager.getEconomy().format(bookPriceQuantity));
|
||||
|
@@ -31,7 +31,7 @@ public class CommandDecrypt implements TabExecutor {
|
||||
StringFormatter stringFormatter = BooksWithoutBorders.getStringFormatter();
|
||||
|
||||
if (!(sender instanceof Player player)) {
|
||||
BooksWithoutBorders.sendErrorMessage(sender, "This command can only be used by a player!");
|
||||
BooksWithoutBorders.getStringFormatter().displayErrorMessage(sender, Translatable.ERROR_PLAYER_ONLY);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -136,7 +136,7 @@ public class CommandSetBookPrice implements TabExecutor {
|
||||
economyManager.getEconomy().format(newPriceQuantity) + "!");
|
||||
return true;
|
||||
} else {
|
||||
BooksWithoutBorders.sendErrorMessage(sender, StaticMessage.EXCEPTION_VAULT_NOT_AVAILABLE.toString());
|
||||
BooksWithoutBorders.sendErrorMessage(sender, StaticMessage.EXCEPTION_VAULT_PRICE_NOT_CHANGED.toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -398,7 +398,8 @@ public class BooksWithoutBordersConfig {
|
||||
this.titleAuthorSeparator = ",";
|
||||
config.set("Options.Title-Author_Separator", this.titleAuthorSeparator);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Exception exception) {
|
||||
logger.log(Level.SEVERE, exception.getMessage());
|
||||
logger.log(Level.SEVERE, "Warning! Config.yml failed to load!\n" +
|
||||
"Try Looking for settings that are missing values!");
|
||||
return false;
|
||||
|
@@ -10,8 +10,8 @@ public enum StaticMessage {
|
||||
BOOK_SAVING_FAILED("Saving failed! Aborting..."),
|
||||
BOOK_FOLDER_CREATE_FAILED("Unable to create necessary folders"),
|
||||
COMMAND_NOT_REGISTERED("Command {command} has not been registered!"),
|
||||
EXCEPTION_VAULT_NOT_AVAILABLE("BooksWithoutBorders failed to hook into Vault! Book price not set!"),
|
||||
;
|
||||
EXCEPTION_VAULT_NOT_AVAILABLE("Vault is unavailable, but book price is set to economy. Unsetting book cost!"),
|
||||
EXCEPTION_VAULT_PRICE_NOT_CHANGED("BooksWithoutBorders failed to hook into Vault! Book price not set!");
|
||||
|
||||
private final @NotNull String messageString;
|
||||
|
||||
|
@@ -8,11 +8,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public enum Translatable implements TranslatableMessage {
|
||||
|
||||
/**
|
||||
* The prefix to display in messages
|
||||
*/
|
||||
PREFIX,
|
||||
|
||||
/**
|
||||
* The success message displayed when the copy command succeeds
|
||||
*/
|
||||
|
@@ -2,7 +2,6 @@ package net.knarcraft.bookswithoutborders.manager;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig;
|
||||
import net.knarcraft.bookswithoutborders.config.StaticMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.Translatable;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.Material;
|
||||
@@ -31,13 +30,13 @@ public class EconomyManager {
|
||||
/**
|
||||
* Instantiates the economy manager
|
||||
*/
|
||||
public EconomyManager() throws IllegalStateException {
|
||||
public EconomyManager() {
|
||||
Server server = BooksWithoutBorders.getInstance().getServer();
|
||||
Plugin plugin = server.getPluginManager().getPlugin("Vault");
|
||||
ServicesManager servicesManager = server.getServicesManager();
|
||||
|
||||
if (plugin == null) {
|
||||
throw new IllegalStateException(StaticMessage.EXCEPTION_VAULT_NOT_AVAILABLE.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
RegisteredServiceProvider<Economy> economyProvider = servicesManager.getRegistration(Economy.class);
|
||||
|
@@ -14,7 +14,7 @@ en:
|
||||
ERROR_BOOK_COPIED_TOO_FAR: "You cannot copy this book any further. You must have the original or a direct copy."
|
||||
ERROR_INVENTORY_FULL: "You need an available slot in your inventory."
|
||||
ERROR_METADATA_MISSING: "Unable to get metadata for the held book!"
|
||||
ERROR_VAULT_COST_BUT_UNAVAILABLE: "The cost was set to economy, but Vault is unavailable!"
|
||||
ERROR_VAULT_COST_BUT_UNAVAILABLE: "&4The cost was set to economy, but Vault is unavailable!"
|
||||
NEUTRAL_COMMANDS_HEADER: |
|
||||
&e[] denote optional parameters
|
||||
<> denote required parameters
|
||||
|
Reference in New Issue
Block a user