diff --git a/build.gradle b/build.gradle index d24275c..71fc963 100644 --- a/build.gradle +++ b/build.gradle @@ -30,6 +30,7 @@ allprojects { maven { url 'https://jitpack.io' } maven { url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' } maven { url 'https://papermc.io/repo/repository/maven-public/' } + maven { url 'https://repo.rosewooddev.io/repository/public/' } } jar { @@ -37,6 +38,7 @@ allprojects { } dependencies { + compileOnly 'org.black_ixx:playerpoints:3.0.0' compileOnly 'com.willfp:eco:6.9.0' compileOnly 'org.jetbrains:annotations:19.0.0' diff --git a/eco-core/core-plugin/build.gradle b/eco-core/core-plugin/build.gradle index 9f02807..27ce8f4 100644 --- a/eco-core/core-plugin/build.gradle +++ b/eco-core/core-plugin/build.gradle @@ -7,6 +7,7 @@ dependencies { compileOnly 'com.willfp:EcoSkills:1.4.0' compileOnly 'com.willfp:Talismans:4.6.0' compileOnly 'com.github.Archy-X:AureliumSkills:Beta1.2.4' + compileOnly 'org.black_ixx:playerpoints:3.0.0' } build.dependsOn publishToMavenLocal diff --git a/eco-core/core-plugin/src/main/java/com/willfp/reforges/ReforgesPlugin.java b/eco-core/core-plugin/src/main/java/com/willfp/reforges/ReforgesPlugin.java index 3447c43..bef983a 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/reforges/ReforgesPlugin.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/reforges/ReforgesPlugin.java @@ -117,6 +117,7 @@ public class ReforgesPlugin extends EcoPlugin { return Arrays.asList( new IntegrationLoader("EcoSkills", EcoSkillsIntegration.INSTANCE::load), new IntegrationLoader("Talismans", TalismansIntegration.INSTANCE::registerProvider), + new IntegrationLoader("PlayerPoints", () -> EconomyHandler.setUsePlayerPoints(true)), new IntegrationLoader("AureliumSkills", AureliumSkillsIntegration.INSTANCE::load) ); } diff --git a/eco-core/core-plugin/src/main/java/com/willfp/reforges/vault/EconomyHandler.java b/eco-core/core-plugin/src/main/java/com/willfp/reforges/vault/EconomyHandler.java index d019bd8..e3a9e12 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/reforges/vault/EconomyHandler.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/reforges/vault/EconomyHandler.java @@ -1,11 +1,18 @@ package com.willfp.reforges.vault; +import com.willfp.reforges.ReforgesPlugin; import lombok.Setter; import lombok.experimental.UtilityClass; import net.milkbowl.vault.economy.Economy; +import org.black_ixx.playerpoints.PlayerPoints; import org.bukkit.Bukkit; +import org.bukkit.entity.Player; import org.bukkit.plugin.RegisteredServiceProvider; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; + @UtilityClass public final class EconomyHandler { /** @@ -13,6 +20,9 @@ public final class EconomyHandler { */ private static Economy instance = null; + @Setter + private static boolean usePlayerPoints = false; + @Setter private static boolean enabled = false; @@ -34,6 +44,18 @@ public final class EconomyHandler { return EconomyHandler.instance; } + public static boolean has(Player player, double amount) { + if (usePlayerPoints && ReforgesPlugin.getInstance().getConfigYml().getBool("reforge.use-player-points")) { + try { + return PlayerPoints.getInstance().getAPI().lookAsync(player.getUniqueId()).get() >= amount; + } catch (ExecutionException | InterruptedException e) { + return false; + } + } + return getInstance().has(player, amount); + + } + public static boolean isEnabled() { return EconomyHandler.enabled; } diff --git a/eco-core/core-plugin/src/main/resources/plugin.yml b/eco-core/core-plugin/src/main/resources/plugin.yml index c4586a9..eb2db95 100644 --- a/eco-core/core-plugin/src/main/resources/plugin.yml +++ b/eco-core/core-plugin/src/main/resources/plugin.yml @@ -13,6 +13,7 @@ softdepend: - EcoSkills - Talismans - AureliumSkills + - PlayerPoints libraries: - 'org.jetbrains.kotlin:kotlin-stdlib:1.5.21'