mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-02-23 14:51:21 +01:00
Added stellium crafting condition
This commit is contained in:
parent
2354211e5c
commit
755dde5475
@ -14,6 +14,7 @@ import net.Indyuce.mmoitems.api.block.CustomBlock;
|
||||
import net.Indyuce.mmoitems.api.crafting.ConditionalDisplay;
|
||||
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;
|
||||
@ -33,96 +34,102 @@ import java.util.Optional;
|
||||
|
||||
public class MMOCoreMMOLoader extends MMOLoader {
|
||||
|
||||
private static final ItemStat MANA_REGENERATION = new DoubleStat("MANA_REGENERATION", VersionMaterial.LAPIS_LAZULI.toMaterial(), "Mana Regeneration",
|
||||
new String[] { "Increases mana regen." });
|
||||
private static final ItemStat MAX_STAMINA = new DoubleStat("MAX_STAMINA", VersionMaterial.LIGHT_BLUE_DYE.toMaterial(), "Max Stamina",
|
||||
new String[] { "Adds stamina to your max stamina bar." });
|
||||
private static final ItemStat STAMINA_REGENERATION = new DoubleStat("STAMINA_REGENERATION", VersionMaterial.LIGHT_BLUE_DYE.toMaterial(),
|
||||
"Stamina Regeneration", new String[] { "Increases stamina regen." });
|
||||
private static final ItemStat ADDITIONAL_EXPERIENCE = new DoubleStat("ADDITIONAL_EXPERIENCE", VersionMaterial.EXPERIENCE_BOTTLE.toMaterial(),
|
||||
"Additional Experience", new String[] { "Additional MMOCore main class experience in %." });
|
||||
private static final ItemStat HEALTH_REGENERATION = new DoubleStat("HEALTH_REGENERATION", Material.BREAD, "Health Regeneration",
|
||||
new String[] { "Increases MMOCore health regen.", "In %." });
|
||||
private static final ItemStat MANA_REGENERATION = new DoubleStat("MANA_REGENERATION", VersionMaterial.LAPIS_LAZULI.toMaterial(), "Mana Regeneration",
|
||||
new String[]{"Increases mana regen."});
|
||||
private static final ItemStat MAX_STAMINA = new DoubleStat("MAX_STAMINA", VersionMaterial.LIGHT_BLUE_DYE.toMaterial(), "Max Stamina",
|
||||
new String[]{"Adds stamina to your max stamina bar."});
|
||||
private static final ItemStat STAMINA_REGENERATION = new DoubleStat("STAMINA_REGENERATION", VersionMaterial.LIGHT_BLUE_DYE.toMaterial(),
|
||||
"Stamina Regeneration", new String[]{"Increases stamina regen."});
|
||||
private static final ItemStat ADDITIONAL_EXPERIENCE = new DoubleStat("ADDITIONAL_EXPERIENCE", VersionMaterial.EXPERIENCE_BOTTLE.toMaterial(),
|
||||
"Additional Experience", new String[]{"Additional MMOCore main class experience in %."});
|
||||
private static final ItemStat HEALTH_REGENERATION = new DoubleStat("HEALTH_REGENERATION", Material.BREAD, "Health Regeneration",
|
||||
new String[]{"Increases MMOCore health regen.", "In %."});
|
||||
|
||||
/*
|
||||
* called when MMOItems loads
|
||||
*/
|
||||
public MMOCoreMMOLoader() {
|
||||
MMOCore.plugin.loadManager.registerLoader(this);
|
||||
MMOCore.plugin.mineManager.registerBlockType(block -> {
|
||||
Optional<CustomBlock> customBlock = MMOItems.plugin.getCustomBlocks().getFromBlock(block.getBlockData());
|
||||
return customBlock.map(MMOItemsBlockType::new);
|
||||
});
|
||||
/*
|
||||
* called when MMOItems loads
|
||||
*/
|
||||
public MMOCoreMMOLoader() {
|
||||
MMOCore.plugin.loadManager.registerLoader(this);
|
||||
MMOCore.plugin.mineManager.registerBlockType(block -> {
|
||||
Optional<CustomBlock> customBlock = MMOItems.plugin.getCustomBlocks().getFromBlock(block.getBlockData());
|
||||
return customBlock.map(MMOItemsBlockType::new);
|
||||
});
|
||||
|
||||
MMOItems.plugin.getStats().register(HEALTH_REGENERATION);
|
||||
MMOItems.plugin.getStats().register(MANA_REGENERATION);
|
||||
MMOItems.plugin.getStats().register(MAX_STAMINA);
|
||||
MMOItems.plugin.getStats().register(STAMINA_REGENERATION);
|
||||
MMOItems.plugin.getStats().register(ADDITIONAL_EXPERIENCE);
|
||||
MMOItems.plugin.getStats().register(HEALTH_REGENERATION);
|
||||
MMOItems.plugin.getStats().register(MANA_REGENERATION);
|
||||
MMOItems.plugin.getStats().register(MAX_STAMINA);
|
||||
MMOItems.plugin.getStats().register(STAMINA_REGENERATION);
|
||||
MMOItems.plugin.getStats().register(ADDITIONAL_EXPERIENCE);
|
||||
|
||||
/*
|
||||
* register extra conditions for MMOItems crafting.
|
||||
*/
|
||||
MMOItems.plugin.getCrafting().registerCondition("profession", ProfessionCondition::new, new ConditionalDisplay(
|
||||
"&a" + AltChar.check + " Requires #level# in #profession#", "&c" + AltChar.cross + " Requires #level# in #profession#"));
|
||||
MMOItems.plugin.getCrafting().registerTrigger("exp", ExperienceCraftingTrigger::new);
|
||||
}
|
||||
/*
|
||||
* register extra conditions for MMOItems crafting.
|
||||
*/
|
||||
MMOItems.plugin.getCrafting().registerCondition("profession", ProfessionCondition::new,
|
||||
new ConditionalDisplay(
|
||||
"&a" + AltChar.check + " Requires #level# in #profession#",
|
||||
"&c" + AltChar.cross + " Requires #level# in #profession#"));
|
||||
MMOItems.plugin.getCrafting().registerCondition("stellium", StelliumCondition::new,
|
||||
new ConditionalDisplay(
|
||||
"&a" + AltChar.check + " Requires #stellium# Stellium",
|
||||
"&c" + AltChar.cross + " Requires #stellium# Stellium"));
|
||||
MMOItems.plugin.getCrafting().registerTrigger("exp", ExperienceCraftingTrigger::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Condition loadCondition(MMOLineConfig config) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Condition loadCondition(MMOLineConfig config) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Trigger loadTrigger(MMOLineConfig config) {
|
||||
@Override
|
||||
public Trigger loadTrigger(MMOLineConfig config) {
|
||||
|
||||
if (config.getKey().equals("mmoitem"))
|
||||
return new MMOItemTrigger(config);
|
||||
if (config.getKey().equals("mmoitem"))
|
||||
return new MMOItemTrigger(config);
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DropItem loadDropItem(MMOLineConfig config) {
|
||||
@Override
|
||||
public DropItem loadDropItem(MMOLineConfig config) {
|
||||
|
||||
if (config.getKey().equals("mmoitem") || config.getKey().equals("mmoitemtemplate"))
|
||||
return new ItemTemplateDropItem(config);
|
||||
if (config.getKey().equals("mmoitem") || config.getKey().equals("mmoitemtemplate"))
|
||||
return new ItemTemplateDropItem(config);
|
||||
|
||||
if (config.getKey().equals("miloot"))
|
||||
return new RandomItemDropItem(config);
|
||||
if (config.getKey().equals("miloot"))
|
||||
return new RandomItemDropItem(config);
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Objective loadObjective(MMOLineConfig config, ConfigurationSection section) {
|
||||
@Override
|
||||
public Objective loadObjective(MMOLineConfig config, ConfigurationSection section) {
|
||||
|
||||
if (config.getKey().equals("getmmoitem"))
|
||||
return new GetMMOItemObjective(section, config);
|
||||
if (config.getKey().equals("getmmoitem"))
|
||||
return new GetMMOItemObjective(section, config);
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExperienceSource<?> loadExperienceSource(MMOLineConfig config, Profession profession) {
|
||||
@Override
|
||||
public ExperienceSource<?> loadExperienceSource(MMOLineConfig config, Profession profession) {
|
||||
|
||||
if (config.getKey().equals("minemiblock"))
|
||||
return new MineMIBlockExperienceSource(profession, config);
|
||||
if (config.getKey().equals("minemiblock"))
|
||||
return new MineMIBlockExperienceSource(profession, config);
|
||||
|
||||
if (config.getKey().equalsIgnoreCase("smeltmmoitem"))
|
||||
return new SmeltMMOItemExperienceSource(profession, config);
|
||||
if (config.getKey().equalsIgnoreCase("smeltmmoitem"))
|
||||
return new SmeltMMOItemExperienceSource(profession, config);
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockType loadBlockType(MMOLineConfig config) {
|
||||
@Override
|
||||
public BlockType loadBlockType(MMOLineConfig config) {
|
||||
|
||||
if (config.getKey().equalsIgnoreCase("miblock") || config.getKey().equals("mmoitemsblock") || config.getKey().equals("mmoitem")
|
||||
|| config.getKey().equals("mmoitems"))
|
||||
return new MMOItemsBlockType(config);
|
||||
if (config.getKey().equalsIgnoreCase("miblock") || config.getKey().equals("mmoitemsblock") || config.getKey().equals("mmoitem")
|
||||
|| config.getKey().equals("mmoitems"))
|
||||
return new MMOItemsBlockType(config);
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package net.Indyuce.mmoitems.comp.mmocore.crafting;
|
||||
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
import net.Indyuce.mmoitems.api.crafting.condition.Condition;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
|
||||
public class StelliumCondition extends Condition {
|
||||
private final double amount;
|
||||
|
||||
public StelliumCondition(MMOLineConfig config) {
|
||||
super("mana");
|
||||
|
||||
config.validate("amount");
|
||||
amount = config.getDouble("amount");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMet(PlayerData data) {
|
||||
return net.Indyuce.mmocore.api.player.PlayerData.get(data.getUniqueId()).getStellium() >= amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatDisplay(String string) {
|
||||
return string.replace("#stellium#", "" + amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCrafting(PlayerData data) {
|
||||
net.Indyuce.mmocore.api.player.PlayerData.get(data.getUniqueId()).giveStellium(-amount);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user