9
0
mirror of https://github.com/Auxilor/Reforges.git synced 2025-12-26 10:29:11 +00:00

Added PlayerPoints integration and "reforge.use-player-points: true/false" for people to use it

This commit is contained in:
_OfTeN_
2021-10-06 22:34:37 +03:00
parent 86eb5ff216
commit 174bd85dc2
5 changed files with 27 additions and 0 deletions

View File

@@ -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

View File

@@ -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)
);
}

View File

@@ -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;
}

View File

@@ -13,6 +13,7 @@ softdepend:
- EcoSkills
- Talismans
- AureliumSkills
- PlayerPoints
libraries:
- 'org.jetbrains.kotlin:kotlin-stdlib:1.5.21'