Uses KnarLib implementation for some methods
All checks were successful
EpicKnarvik97/Books-Without-Borders/pipeline/head This commit looks good
All checks were successful
EpicKnarvik97/Books-Without-Borders/pipeline/head This commit looks good
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -125,7 +125,7 @@
|
||||
<dependency>
|
||||
<groupId>net.knarcraft</groupId>
|
||||
<artifactId>knarlib</artifactId>
|
||||
<version>1.2.12</version>
|
||||
<version>1.2.14</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@@ -47,23 +47,19 @@ import net.knarcraft.bookswithoutborders.listener.PlayerEventListener;
|
||||
import net.knarcraft.bookswithoutborders.listener.SignEventListener;
|
||||
import net.knarcraft.bookswithoutborders.utility.BookFileUtil;
|
||||
import net.knarcraft.bookswithoutborders.utility.InputCleaningUtil;
|
||||
import net.knarcraft.knarlib.config.StargateYamlConfiguration;
|
||||
import net.knarcraft.knarlib.formatting.FormatBuilder;
|
||||
import net.knarcraft.knarlib.formatting.StringFormatter;
|
||||
import net.knarcraft.knarlib.formatting.Translator;
|
||||
import net.knarcraft.knarlib.plugin.ConfigCommentPlugin;
|
||||
import net.knarcraft.knarlib.property.ColorConversion;
|
||||
import net.knarcraft.knarlib.util.ConfigHelper;
|
||||
import net.knarcraft.knarlib.util.UpdateChecker;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemFactory;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -81,7 +77,7 @@ import java.util.logging.Level;
|
||||
/**
|
||||
* The main Books Without Borders class
|
||||
*/
|
||||
public class BooksWithoutBorders extends JavaPlugin {
|
||||
public class BooksWithoutBorders extends ConfigCommentPlugin {
|
||||
|
||||
private static BooksWithoutBorders booksWithoutBorders;
|
||||
|
||||
@@ -93,7 +89,6 @@ public class BooksWithoutBorders extends JavaPlugin {
|
||||
private BookshelfHandler bookshelfHandler;
|
||||
private BwBConfig booksWithoutBordersConfig;
|
||||
private final Queue<MigrationRequest> migrationQueue = new LinkedList<>();
|
||||
private FileConfiguration configuration = null;
|
||||
|
||||
/**
|
||||
* Logs a message to the console
|
||||
@@ -198,32 +193,13 @@ public class BooksWithoutBorders extends JavaPlugin {
|
||||
getInstance().playerLetterIndex = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
this.configuration = StargateYamlConfiguration.loadConfiguration(this, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveConfig() {
|
||||
StargateYamlConfiguration.saveConfiguration(this, this.configuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public FileConfiguration getConfig() {
|
||||
if (this.configuration == null) {
|
||||
this.reloadConfig();
|
||||
}
|
||||
return this.configuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
booksWithoutBorders = this;
|
||||
ConfigHelper.saveDefaults(this);
|
||||
|
||||
//Migrate from an earlier configuration file syntax if necessary
|
||||
if (this.configuration.getString("Options.Save_Books_in_Yaml_Format") != null) {
|
||||
if (getConfig().getString("Options.Save_Books_in_Yaml_Format") != null) {
|
||||
ConfigHelper.migrateConfig(this);
|
||||
}
|
||||
|
||||
@@ -320,22 +296,6 @@ public class BooksWithoutBorders extends JavaPlugin {
|
||||
registerCommand(BwBCommand.CREATE_BWB_SIGN.toString(), new CommandCreateBwBSign());
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a command
|
||||
*
|
||||
* @param commandName <p>The name of the command to register</p>
|
||||
* @param executor <p>The executor to register for the command</p>
|
||||
*/
|
||||
private void registerCommand(@NotNull String commandName, @NotNull CommandExecutor executor) {
|
||||
PluginCommand pluginCommand = this.getCommand(commandName);
|
||||
if (pluginCommand != null) {
|
||||
pluginCommand.setExecutor(executor);
|
||||
} else {
|
||||
getLogger().log(Level.SEVERE, new FormatBuilder(StaticMessage.EXCEPTION_COMMAND_REGISTRATION_FAILED.toString()).
|
||||
replace(Placeholder.COMMAND, commandName).toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the plugin, loading and fixing the config file
|
||||
*
|
||||
|
Reference in New Issue
Block a user