Skip to content

Commit

Permalink
Forever fix compatibility with other plugins.
Browse files Browse the repository at this point in the history
  • Loading branch information
vLuckyyy committed Dec 29, 2024
1 parent 5bc160a commit 3f814dc
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 16 deletions.
20 changes: 10 additions & 10 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@ object Versions {

const val SPIGOT_API = "1.19.4-R0.1-SNAPSHOT"

const val OKAERI_CONFIGS = "5.0.5"
const val LITE_COMMANDS = "3.7.1"
const val OKAERI_CONFIGS = "5.0.3"
const val LITE_COMMANDS = "3.6.0-SNAPSHOT"

const val ETERNALCODE_COMMONS = "1.1.4"
const val MULTIFICATION = "1.1.4"
const val ETERNALCODE_COMMONS = "1.1.5"
const val MULTIFICATION = "1.1.3"

const val JETBRAINS_ANNOTATIONS = "26.0.1"
const val JETBRAINS_ANNOTATIONS = "24.1.0"

const val ADVENTURE_PLATFORM_BUKKIT = "4.3.4"
const val ADVENTURE_PLATFORM_BUKKIT = "4.3.3"
const val ADVENTURE_API = "4.17.0"

const val VAULT_API = "1.7.1"
const val VAULT_API = "1.7"

const val PLACEHOLDER_API = "2.11.6"

const val MARIA_DB = "3.4.1"
const val POSTGRESQL = "42.7.4"
const val H2 = "2.3.232"
const val POSTGRESQL = "42.7.3"
const val H2 = "2.1.214"
const val ORMLITE = "6.1"
const val HIKARI_CP = "6.0.0"
const val HIKARI_CP = "5.1.0"
}
6 changes: 6 additions & 0 deletions eternaleconomy-core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import net.minecrell.pluginyml.bukkit.BukkitPluginDescription

plugins {
`economy-java`
`economy-repositories`
Expand Down Expand Up @@ -68,6 +70,10 @@ bukkit {
author = "EternalCodeTeam"
name = "EternalEconomy"
website = "www.eternalcode.pl"
// Enabling this option previously caused issues where the plugin was loaded before Vault,
// preventing the Vault Economy Provider from registering and causing dependent plugins to malfunction.
// Setting the load order to startup ensures the economy plugin is one of the first to load, avoiding these issues.
load = BukkitPluginDescription.PluginLoadOrder.STARTUP
version = "${project.version}"

depend = listOf("Vault")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public void onEnable() {
accountManager,
decimalFormatter,
server,
this,
this.getLogger()
);
bridgeManager.init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import com.eternalcode.economy.bridge.placeholderapi.PlaceholderEconomyExpansion;
import com.eternalcode.economy.format.DecimalFormatter;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager;

Expand All @@ -16,30 +18,44 @@ public class BridgeManager {
private final DecimalFormatter decimalFormatter;

private final Server server;
private final Plugin plugin;
private final Logger logger;

public BridgeManager(
PluginDescriptionFile pluginDescriptionFile,
AccountManager accountManager,
DecimalFormatter decimalFormatter,
Server server,
Plugin plugin,
Logger logger
) {
this.pluginDescriptionFile = pluginDescriptionFile;
this.accountManager = accountManager;
this.decimalFormatter = decimalFormatter;
this.server = server;
this.plugin = plugin;
this.logger = logger;
}

public void init() {
this.setupBridge("PlaceholderAPI", () -> {
new PlaceholderEconomyExpansion(
this.pluginDescriptionFile,
this.accountManager,
this.decimalFormatter
).initialize();
// Using "load: STARTUP" in plugin.yml causes the plugin to load before PlaceholderAPI.
// Therefore, we need to delay the bridge initialization until the server is fully started.
// The scheduler runs the code after the "Done" message, ensuring the server is fully operational.
Bukkit.getScheduler().runTask(this.plugin, () -> {
this.setupBridge("PlaceholderAPI", () -> {
PlaceholderEconomyExpansion placeholderEconomyExpansion = new PlaceholderEconomyExpansion(
this.pluginDescriptionFile,
this.accountManager,
this.decimalFormatter
);

placeholderEconomyExpansion.register();

System.out.println("PlaceholderAPI bridge initialized!");
});
});

// other bridges (do not put bridges in the scheduler if not needed)
}

private void setupBridge(String pluginName, BridgeInitializer bridge) {
Expand Down

0 comments on commit 3f814dc

Please sign in to comment.