Skip to content

Commit

Permalink
New changes
Browse files Browse the repository at this point in the history
  • Loading branch information
staFF6773 authored Mar 31, 2024
1 parent a2b001e commit e388128
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
34 changes: 23 additions & 11 deletions src/main/java/io/github/sstudiosdev/BetterPvP.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public final class BetterPvP extends JavaPlugin {

@Getter
private VaultHookManager vaultHookManager;
private boolean loadLicenseFile;

/**
* Method called when the plugin is enabled.
Expand All @@ -48,17 +49,19 @@ public void onEnable() {
displayConsoleInfo();

// Copy Apache-2.0 license file from resources to plugin folder
try {
File licenseFile = new File(getDataFolder(), "Apache-2.0 license");
if (!licenseFile.exists()) {
InputStream inputStream = getResource("Apache-2.0 license");
Files.copy(inputStream, licenseFile.toPath());
getLogger().info("License file 'Apache-2.0' loaded successfully.");
} else {
getLogger().info("License file 'Apache-2.0' already exists.");
if (mainConfig.getBoolean("load-license-file")) {
try {
File licenseFile = new File(getDataFolder(), "Apache-2.0 license");
if (!licenseFile.exists()) {
InputStream inputStream = getResource("Apache-2.0 license");
Files.copy(inputStream, licenseFile.toPath());
getLogger().info("License file 'Apache-2.0' loaded successfully.");
} else {
getLogger().info("License file 'Apache-2.0' already exists.");
}
} catch (IOException e) {
getLogger().warning("Failed to load license file 'Apache-2.0'. Reason: " + e.getMessage());
}
} catch (IOException e) {
getLogger().warning("Failed to load license file 'Apache-2.0'. Reason: " + e.getMessage());
}
}

Expand Down Expand Up @@ -88,6 +91,15 @@ private void loadConfiguration() {

// Get prefix from configuration
prefix = mainConfig.getString("prefix");

// Check if the plugin should load the license file
if (mainConfig.contains("load-license-file")) {
loadLicenseFile = mainConfig.getBoolean("load-license-file");
} else {
// Default value if not specified in config
loadLicenseFile = true;
}

}

/**
Expand Down Expand Up @@ -127,4 +139,4 @@ private void sendMessageToConsole(String message) {
Bukkit.getConsoleSender().sendMessage(ChatColorUtil.colorize(message));
}

}
}
1 change: 1 addition & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# For example, prefix and other basic settings.

prefix: "&8[&3BetterPvP&8]"
load-license-file: true

# ============================================================
# | Messages |
Expand Down

0 comments on commit e388128

Please sign in to comment.