Skip to content

Commit

Permalink
Load libraries after options declared
Browse files Browse the repository at this point in the history
  • Loading branch information
srnyx committed Jan 19, 2025
1 parent 87cedf6 commit 7d41870
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/main/java/xyz/srnyx/annoyingapi/AnnoyingPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@ public void log(@NotNull LogRecord logRecord) {
*/
public AnnoyingPlugin() {
LOGGER = getLogger();

// Load required libraries
options.pluginOptions.libraries.forEach(libraryManager::loadLibrary);
}

/**
Expand Down Expand Up @@ -232,8 +229,10 @@ public void reload() {
* @see #enable()
*/
private void enablePlugin() {
final String name = getName();

// Check if they're trying to use API as standalone plugin
if (getName().equals("AnnoyingAPI")) {
if (name.equals("AnnoyingAPI")) {
String hideMessage = "";
try {
hideMessage = " To hide this message: delete &4" + new File(getClass().getProtectionDomain().getCodeSource().getLocation().toURI()).getPath();
Expand All @@ -249,11 +248,14 @@ private void enablePlugin() {
.map(dependency -> dependency.name)
.collect(Collectors.joining("&c, &4"));
if (!missing.isEmpty()) {
log(Level.SEVERE, "&cDisabling &4" + getName() + "&c because it's missing required dependencies: &4" + missing);
log(Level.SEVERE, "&cDisabling &4" + name + "&c because it's missing required dependencies: &4" + missing);
disablePlugin();
return;
}

// Load required libraries
options.pluginOptions.libraries.forEach(libraryManager::loadLibrary);

// Enable bStats
if (new AnnoyingResource(this, options.bStatsOptions.fileName, options.bStatsOptions.fileOptions).getBoolean(options.bStatsOptions.toggleKey)) {
libraryManager.loadLibrary(RuntimeLibrary.BSTATS_BASE);
Expand All @@ -269,7 +271,7 @@ private void enablePlugin() {

// Get start messages
final PluginDescriptionFile description = getDescription();
final String nameVersion = getName() + " v" + description.getVersion();
final String nameVersion = name + " v" + description.getVersion();
final String authors = "By " + String.join(", ", description.getAuthors());
final StringBuilder lineBuilder = new StringBuilder(secondaryColor);
final int lineLength = Math.max(nameVersion.length(), authors.length());
Expand Down

0 comments on commit 7d41870

Please sign in to comment.