Improved support for Vault

This commit is contained in:
Indyuce 2022-08-20 20:25:39 +02:00
parent 5a0f51331c
commit 75fe7a737b
2 changed files with 12 additions and 11 deletions

View File

@ -241,12 +241,11 @@ public class PlayerData {
// Apply permissions if Vault exists
if (MMOItems.plugin.hasPermissions() && item.hasData(ItemStats.GRANTED_PERMISSIONS)) {
final Permission perms = MMOItems.plugin.getVault().getPermissions();
permissions.addAll(((StringListData) item.getData(ItemStats.GRANTED_PERMISSIONS)).getList());
Permission perms = MMOItems.plugin.getVault().getPermissions();
permissions.forEach(perm -> {
if (!perms.has(getPlayer(), perm)) {
if (!perms.has(getPlayer(), perm))
perms.playerAdd(getPlayer(), perm);
}
});
}
}
@ -281,10 +280,12 @@ public class PlayerData {
// Apply item set bonuses
if (setBonuses != null) {
if (MMOItems.plugin.hasPermissions()) {
final Permission perms = MMOItems.plugin.getVault().getPermissions();
for (String perm : setBonuses.getPermissions())
if (!perms.has(getPlayer(), perm))
perms.playerAdd(getPlayer(), perm);
}
for (AbilityData ability : setBonuses.getAbilities())
mmoData.getPassiveSkillMap().addModifier(new PassiveSkill("MMOItemsItem", ability, EquipmentSlot.OTHER, ModifierSource.OTHER));
for (ParticleData particle : setBonuses.getParticles())

View File

@ -1,9 +1,10 @@
package net.Indyuce.mmoitems.comp.eco;
import io.lumine.mythic.lib.api.MMOLineConfig;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.crafting.condition.Condition;
import net.Indyuce.mmoitems.api.player.PlayerData;
import io.lumine.mythic.lib.api.MMOLineConfig;
import org.apache.commons.lang.Validate;
public class MoneyCondition extends Condition {
private final double amount;
@ -11,13 +12,13 @@ public class MoneyCondition extends Condition {
public MoneyCondition(MMOLineConfig config) {
super("money");
config.validate("amount");
Validate.isTrue(MMOItems.plugin.hasEconomy(), "No economy plugin found");
config.validateKeys("amount");
amount = config.getDouble("amount");
}
@Override
public boolean isMet(PlayerData data) {
if(!data.isOnline()) return false;
return MMOItems.plugin.getVault().getEconomy().has(data.getPlayer(), amount);
}
@ -28,7 +29,6 @@ public class MoneyCondition extends Condition {
@Override
public void whenCrafting(PlayerData data) {
if(!data.isOnline()) return;
MMOItems.plugin.getVault().getEconomy().withdrawPlayer(data.getPlayer(), amount);
}
}