9
0
mirror of https://github.com/Auxilor/Reforges.git synced 2025-12-25 01:49:34 +00:00

Merge pull request #5

UltimateSkills integration (2 effects) and PlayerPoints integration
This commit is contained in:
Will FP
2021-10-27 18:59:38 +01:00
committed by GitHub
11 changed files with 134 additions and 0 deletions

View File

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

View File

@@ -2,11 +2,14 @@ group 'com.willfp'
version rootProject.version
dependencies {
compileOnly fileTree(dir: '../../lib', include: ['*.jar'])
compileOnly 'io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT'
compileOnly 'com.github.MilkBowl:VaultAPI:1.7'
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'
compileOnly fileTree(dir: '../../lib', include: ['*.jar'])
}
build.dependsOn publishToMavenLocal

View File

@@ -16,6 +16,7 @@ import com.willfp.reforges.effects.Effects;
import com.willfp.reforges.integrations.aureliumskills.AureliumSkillsIntegration;
import com.willfp.reforges.integrations.ecoskills.EcoSkillsIntegration;
import com.willfp.reforges.integrations.talismans.TalismansIntegration;
import com.willfp.reforges.integrations.ultimateskills.UltimateSkillsIntegration;
import com.willfp.reforges.reforges.Reforge;
import com.willfp.reforges.reforges.Reforges;
import com.willfp.reforges.reforges.util.ReforgeArgParser;
@@ -128,8 +129,10 @@ public class ReforgesPlugin extends EcoPlugin {
@Override
protected List<IntegrationLoader> loadIntegrationLoaders() {
return Arrays.asList(
new IntegrationLoader("UltimateSkills", UltimateSkillsIntegration.INSTANCE::load),
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

@@ -0,0 +1,41 @@
package com.willfp.reforges.integrations.ultimateskills
import com.willfp.eco.core.config.interfaces.JSONConfig
import com.willfp.eco.util.NumberUtils
import com.willfp.reforges.ReforgesPlugin
import com.willfp.reforges.effects.Effect
import mc.ultimatecore.skills.HyperSkills
import mc.ultimatecore.skills.objects.abilities.Ability
import mc.ultimatecore.skills.objects.perks.Perk
import org.bukkit.entity.Player
import org.bukkit.persistence.PersistentDataType
class EffectAddAbility : Effect("add_ultimateskills_ability") {
override fun handleEnable(
player: Player,
config: JSONConfig
) {
HyperSkills.getInstance().api.addAbility(
player.uniqueId,
Ability.valueOf(config.getString("ability", false)),
config.getDouble("amount")
)
player.persistentDataContainer.set(
ReforgesPlugin.getInstance().namespacedKeyFactory.create("addAbility"), PersistentDataType.STRING,
NumberUtils.format(config.getDouble("amount")) + "::" + config.getString("ability", false)
)
}
override fun handleDisable(player: Player) {
player.persistentDataContainer.get(ReforgesPlugin.getInstance().namespacedKeyFactory.create("addAbility"), PersistentDataType.STRING)
?.let {
HyperSkills.getInstance().api.removeAbility(
player.uniqueId,
Ability.valueOf(it.split("::")[1]),
it.split("::")[0].toDouble()
)
}
}
}

View File

@@ -0,0 +1,43 @@
package com.willfp.reforges.integrations.ultimateskills
import com.archyx.aureliumskills.api.AureliumAPI
import com.archyx.aureliumskills.stats.Stats
import com.willfp.eco.core.config.interfaces.JSONConfig
import com.willfp.eco.util.NumberUtils
import com.willfp.reforges.ReforgesPlugin
import com.willfp.reforges.effects.Effect
import com.willfp.reforges.effects.getEffectAmount
import mc.ultimatecore.skills.HyperSkills
import mc.ultimatecore.skills.api.HyperSkillsAPI
import mc.ultimatecore.skills.objects.perks.Perk
import org.bukkit.entity.Player
import org.bukkit.persistence.PersistentDataType
class EffectAddPerk : Effect("add_ultimateskills_perk") {
override fun handleEnable(
player: Player,
config: JSONConfig
) {
HyperSkills.getInstance().api.addPerk(
player.uniqueId,
Perk.valueOf(config.getString("perk", false)),
config.getDouble("amount")
)
player.persistentDataContainer.set(ReforgesPlugin.getInstance().namespacedKeyFactory.create("addPerk"), PersistentDataType.STRING,
NumberUtils.format(config.getDouble("amount")) + "::" + config.getString("perk", false)
)
}
override fun handleDisable(player: Player) {
player.persistentDataContainer.get(ReforgesPlugin.getInstance().namespacedKeyFactory.create("addPerk"), PersistentDataType.STRING)
?.let {
HyperSkills.getInstance().api.removePerk(
player.uniqueId,
Perk.valueOf(it.split("::")[1]),
it.split("::")[0].toDouble()
)
}
}
}

View File

@@ -0,0 +1,18 @@
package com.willfp.reforges.integrations.ultimateskills
import com.willfp.eco.core.integrations.Integration
import com.willfp.reforges.effects.Effect
object UltimateSkillsIntegration : Integration {
private lateinit var ADD_PERK: Effect
private lateinit var ADD_ABILITY: Effect
fun load() {
ADD_PERK = EffectAddPerk()
ADD_ABILITY = EffectAddAbility()
}
override fun getPluginName(): String {
return "UltimateSkills"
}
}

View File

@@ -123,6 +123,7 @@ gui:
reforge:
cost: 7500
xp-cost: 0 # In levels
use-player-points: false
cost-exponent: 1.15 # (Reforges done ^ cost exponent) * cost

View File

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

BIN
lib/UltimateHelper.jar Normal file

Binary file not shown.

BIN
lib/UltimateSkills.jar Normal file

Binary file not shown.