New MMOCore attribute crafting condition

This commit is contained in:
Jules 2021-07-24 20:19:07 +02:00
parent a7749365cf
commit e791926ddb
2 changed files with 48 additions and 10 deletions

View File

@ -1,5 +1,8 @@
package net.Indyuce.mmoitems.comp.mmocore;
import io.lumine.mythic.lib.api.MMOLineConfig;
import io.lumine.mythic.lib.api.util.AltChar;
import io.lumine.mythic.lib.version.VersionMaterial;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.block.BlockType;
import net.Indyuce.mmocore.api.droptable.condition.Condition;
@ -12,21 +15,13 @@ import net.Indyuce.mmocore.api.quest.trigger.Trigger;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.block.CustomBlock;
import net.Indyuce.mmoitems.api.crafting.ConditionalDisplay;
import net.Indyuce.mmoitems.comp.mmocore.crafting.AttributeCondition;
import net.Indyuce.mmoitems.comp.mmocore.crafting.ExperienceCraftingTrigger;
import net.Indyuce.mmoitems.comp.mmocore.crafting.ProfessionCondition;
import net.Indyuce.mmoitems.comp.mmocore.crafting.StelliumCondition;
import net.Indyuce.mmoitems.comp.mmocore.load.GetMMOItemObjective;
import net.Indyuce.mmoitems.comp.mmocore.load.ItemTemplateDropItem;
import net.Indyuce.mmoitems.comp.mmocore.load.MMOItemTrigger;
import net.Indyuce.mmoitems.comp.mmocore.load.MMOItemsBlockType;
import net.Indyuce.mmoitems.comp.mmocore.load.MineMIBlockExperienceSource;
import net.Indyuce.mmoitems.comp.mmocore.load.RandomItemDropItem;
import net.Indyuce.mmoitems.comp.mmocore.load.SmeltMMOItemExperienceSource;
import net.Indyuce.mmoitems.comp.mmocore.load.*;
import net.Indyuce.mmoitems.stat.type.DoubleStat;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import io.lumine.mythic.lib.api.MMOLineConfig;
import io.lumine.mythic.lib.api.util.AltChar;
import io.lumine.mythic.lib.version.VersionMaterial;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
@ -72,6 +67,10 @@ public class MMOCoreMMOLoader extends MMOLoader {
new ConditionalDisplay(
"&a" + AltChar.check + " Requires #stellium# Stellium",
"&c" + AltChar.cross + " Requires #stellium# Stellium"));
MMOItems.plugin.getCrafting().registerCondition("attribute", AttributeCondition::new,
new ConditionalDisplay(
"&a" + AltChar.check + " Requires #points# #attribute#",
"&c" + AltChar.cross + " Requires #points# #attribute#"));
MMOItems.plugin.getCrafting().registerTrigger("exp", ExperienceCraftingTrigger::new);
}

View File

@ -0,0 +1,39 @@
package net.Indyuce.mmoitems.comp.mmocore.crafting;
import io.lumine.mythic.lib.api.MMOLineConfig;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute;
import net.Indyuce.mmoitems.api.crafting.condition.Condition;
import org.apache.commons.lang.Validate;
public class AttributeCondition extends Condition {
private final PlayerAttribute attribute;
private final int points;
public AttributeCondition(MMOLineConfig config) {
super("attribute");
config.validate("attribute", "points");
points = config.getInt("points");
String id = config.getString("attribute").toLowerCase().replace("_", "-");
Validate.isTrue(MMOCore.plugin.attributeManager.has(id), "Could not find attribute " + id);
attribute = MMOCore.plugin.attributeManager.get(id);
}
@Override
public String formatDisplay(String string) {
return string.replace("#level#", "" + points).replace("#attribute#", attribute.getName());
}
@Override
public boolean isMet(net.Indyuce.mmoitems.api.player.PlayerData data) {
return PlayerData.get(data.getUniqueId()).getAttributes().getAttribute(attribute) >= points;
}
@Override
public void whenCrafting(net.Indyuce.mmoitems.api.player.PlayerData data) {
}
}