9
0
mirror of https://github.com/Auxilor/Reforges.git synced 2026-01-04 15:41:40 +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

@@ -30,6 +30,7 @@ allprojects {
maven { url 'https://jitpack.io' } maven { url 'https://jitpack.io' }
maven { url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' } maven { url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
maven { url 'https://papermc.io/repo/repository/maven-public/' } maven { url 'https://papermc.io/repo/repository/maven-public/' }
maven { url 'https://repo.rosewooddev.io/repository/public/' }
} }
jar { jar {
@@ -37,6 +38,7 @@ allprojects {
} }
dependencies { dependencies {
compileOnly 'org.black_ixx:playerpoints:3.0.0'
compileOnly 'com.willfp:eco:6.9.0' compileOnly 'com.willfp:eco:6.9.0'
compileOnly 'org.jetbrains:annotations:19.0.0' compileOnly 'org.jetbrains:annotations:19.0.0'

View File

@@ -7,6 +7,7 @@ dependencies {
compileOnly 'com.willfp:EcoSkills:1.4.0' compileOnly 'com.willfp:EcoSkills:1.4.0'
compileOnly 'com.willfp:Talismans:4.6.0' compileOnly 'com.willfp:Talismans:4.6.0'
compileOnly 'com.github.Archy-X:AureliumSkills:Beta1.2.4' compileOnly 'com.github.Archy-X:AureliumSkills:Beta1.2.4'
compileOnly 'org.black_ixx:playerpoints:3.0.0'
} }
build.dependsOn publishToMavenLocal build.dependsOn publishToMavenLocal

View File

@@ -117,6 +117,7 @@ public class ReforgesPlugin extends EcoPlugin {
return Arrays.asList( return Arrays.asList(
new IntegrationLoader("EcoSkills", EcoSkillsIntegration.INSTANCE::load), new IntegrationLoader("EcoSkills", EcoSkillsIntegration.INSTANCE::load),
new IntegrationLoader("Talismans", TalismansIntegration.INSTANCE::registerProvider), new IntegrationLoader("Talismans", TalismansIntegration.INSTANCE::registerProvider),
new IntegrationLoader("PlayerPoints", () -> EconomyHandler.setUsePlayerPoints(true)),
new IntegrationLoader("AureliumSkills", AureliumSkillsIntegration.INSTANCE::load) new IntegrationLoader("AureliumSkills", AureliumSkillsIntegration.INSTANCE::load)
); );
} }

View File

@@ -1,11 +1,18 @@
package com.willfp.reforges.vault; package com.willfp.reforges.vault;
import com.willfp.reforges.ReforgesPlugin;
import lombok.Setter; import lombok.Setter;
import lombok.experimental.UtilityClass; import lombok.experimental.UtilityClass;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import org.black_ixx.playerpoints.PlayerPoints;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.RegisteredServiceProvider;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
@UtilityClass @UtilityClass
public final class EconomyHandler { public final class EconomyHandler {
/** /**
@@ -13,6 +20,9 @@ public final class EconomyHandler {
*/ */
private static Economy instance = null; private static Economy instance = null;
@Setter
private static boolean usePlayerPoints = false;
@Setter @Setter
private static boolean enabled = false; private static boolean enabled = false;
@@ -34,6 +44,18 @@ public final class EconomyHandler {
return EconomyHandler.instance; 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() { public static boolean isEnabled() {
return EconomyHandler.enabled; return EconomyHandler.enabled;
} }

View File

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