Changed default MMOCore item reqs lore display

This commit is contained in:
Jules 2024-07-27 13:32:18 -07:00
parent 25391e5d9b
commit 87fc363828
4 changed files with 40 additions and 72 deletions

View File

@ -1,52 +1,37 @@
package net.Indyuce.mmoitems.comp.mmocore.stat;
import io.lumine.mythic.lib.UtilityMethods;
import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.player.RPGPlayer;
import net.Indyuce.mmoitems.api.util.message.Message;
import net.Indyuce.mmoitems.stat.data.DoubleData;
import net.Indyuce.mmoitems.stat.type.DoubleStat;
import net.Indyuce.mmoitems.stat.type.GemStoneStat;
import net.Indyuce.mmoitems.stat.type.ItemRestriction;
import net.Indyuce.mmoitems.stat.type.RequiredLevelStat;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.jetbrains.annotations.NotNull;
public class RequiredAttribute extends DoubleStat implements ItemRestriction, GemStoneStat {
public class RequiredAttribute extends RequiredLevelStat {
private final PlayerAttribute attribute;
// TODO merge with RequiredLevelStat
public RequiredAttribute(PlayerAttribute attribute) {
super("REQUIRED_" + attribute.getId().toUpperCase().replace("-", "_"), Material.GRAY_DYE, attribute.getName() + " Requirement (MMOCore)", new String[]{"Amount of " + attribute.getName() + " points the", "player needs to use the item."}, new String[]{"!block", "all"});
super(UtilityMethods.enumName(attribute.getId()), Material.GRAY_DYE, attribute.getName() + " (MMOCore)", new String[]{"Amount of " + attribute.getName() + " points the", "player needs to use the item."});
this.attribute = attribute;
}
@Override
public boolean canUse(RPGPlayer player, NBTItem item, boolean message) {
final int requirement = item.getInteger(this.getNBTPath());
if (requirement <= 0) return true;
final PlayerData mmocorePlayerData = PlayerData.get(player.getPlayer());
if (mmocorePlayerData.getAttributes().getAttribute(attribute) < item.getStat(getId())) {
if (message) {
Message.NOT_ENOUGH_ATTRIBUTE.format(ChatColor.RED, "#attribute#", attribute.getName()).send(player.getPlayer());
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1.5f);
}
return false;
if (mmocorePlayerData.getAttributes().getAttribute(attribute) >= requirement) return true;
if (message) {
Message.NOT_ENOUGH_ATTRIBUTE.format(ChatColor.RED, "#attribute#", attribute.getName()).send(player.getPlayer());
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1.5f);
}
return true;
}
@Override
@Deprecated
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull DoubleData data) {
// Lore Management
int lvl = (int) Math.round(data.getValue());
item.getLore().insert(getPath(), DoubleStat.formatPath(getPath(), getGeneralStatFormat(), false, false, lvl));
// Insert NBT
item.addItemTag(getAppliedNBT(data));
return false;
}
}

View File

@ -1,53 +1,37 @@
package net.Indyuce.mmoitems.comp.mmocore.stat;
import io.lumine.mythic.lib.UtilityMethods;
import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.experience.Profession;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.player.RPGPlayer;
import net.Indyuce.mmoitems.api.util.message.Message;
import net.Indyuce.mmoitems.stat.data.DoubleData;
import net.Indyuce.mmoitems.stat.type.DoubleStat;
import net.Indyuce.mmoitems.stat.type.GemStoneStat;
import net.Indyuce.mmoitems.stat.type.ItemRestriction;
import net.Indyuce.mmoitems.stat.type.RequiredLevelStat;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.jetbrains.annotations.NotNull;
public class RequiredProfession extends DoubleStat implements ItemRestriction, GemStoneStat {
public class RequiredProfession extends RequiredLevelStat {
private final Profession profession;
// TODO merge with RequiredLevelStat
public RequiredProfession(Profession profession) {
super("PROFESSION_" + profession.getId().toUpperCase().replace("-", "_"), Material.PINK_DYE, profession.getName() + " Requirement (MMOCore)",
new String[]{"Amount of " + profession.getName() + " levels the", "player needs to use the item."}, new String[]{"!block", "all"});
super(true, "PROFESSION_" + UtilityMethods.enumName(profession.getId()), Material.PINK_DYE, profession.getName() + " Level (MMOCore)", new String[]{"Amount of " + profession.getName() + " levels the", "player needs to use the item."});
this.profession = profession;
}
@Override
public boolean canUse(RPGPlayer player, NBTItem item, boolean message) {
final int requirement = item.getInteger(this.getNBTPath());
if (requirement <= 0) return true;
final PlayerData mmocorePlayerData = PlayerData.get(player.getPlayer());
if (mmocorePlayerData.getCollectionSkills().getLevel(this.profession) < item.getStat(getId())) {
if (message) {
Message.NOT_ENOUGH_PROFESSION.format(ChatColor.RED, "#profession#", profession.getName()).send(player.getPlayer());
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1.5f);
}
return false;
if (mmocorePlayerData.getCollectionSkills().getLevel(this.profession) >= requirement) return true;
if (message) {
Message.NOT_ENOUGH_PROFESSION.format(ChatColor.RED, "#profession#", profession.getName()).send(player.getPlayer());
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1.5f);
}
return true;
}
@Override
@Deprecated
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull DoubleData data) {
// Lore Management
int lvl = (int) Math.round(data.getValue());
item.getLore().insert(getPath(), DoubleStat.formatPath(getPath(), getGeneralStatFormat(), false, false, lvl));
// Insert NBT
item.addItemTag(getAppliedNBT(data));
return false;
}
}

View File

@ -13,14 +13,10 @@ lore-format:
- '{bar}'
- '#required-class#'
- '#required-level#'
- '#required-dexterity#'
- '#required-dexterity#' # MMOCore attribute requirements
- '#required-strength#'
- '#required-intelligence#'
- '#success-rate#'
- '{bar}'
- '#soulbound#'
# - '{bar}&8&m--------&f&l &nProfessions&8 &m--------------'
- '#profession-alchemy#'
- '#profession-alchemy#' # MMOCore profession requirements
- '#profession-enchanting#'
- '#profession-farming#'
- '#profession-fishing#'
@ -28,7 +24,10 @@ lore-format:
- '#profession-smelting#'
- '#profession-smithing#'
- '#profession-woodcutting#'
# - '{bar}&8&m--------&f&l &nStatistics&8 &m-------------'
- '#success-rate#'
- '{bar}'
- '#soulbound#'
# - '{bar}&8&m--------&f&l &nItem Stats&8 &m-------------'
- '{bar}'
- '#custom-myluck#'
- '#can-identify#'

View File

@ -149,14 +149,14 @@ additional-strength: '&3 &7■ Extra Strength: &f<plus>{value}'
additional-intelligence: '&3 &7■ Extra Intelligence: &f<plus>{value}'
# Professions
profession-alchemy: '&eAlchemy Level: &c{value}'
profession-enchanting: '&eEnchanting Level: &c{value}'
profession-farming: '&eFarming Level: &c{value}'
profession-fishing: '&eFishing Level: &c{value}'
profession-mining: '&eMining Level: &c{value}'
profession-smelting: '&eSmelting Level: &c{value}'
profession-smithing: '&eSmithing Level: &c{value}'
profession-woodcutting: '&eWoodcutting Level: &c{value}'
profession-alchemy: '&eRequires Alchemy Lvl {value}'
profession-enchanting: '&eRequires Enchanting Lvl {value}'
profession-farming: '&eRequires Farming Lvl {value}'
profession-fishing: '&eRequires Fishing Lvl {value}'
profession-mining: '&eRequires Mining Lvl {value}'
profession-smelting: '&eRequires Smelting Lvl {value}'
profession-smithing: '&eRequires Smithing Lvl {value}'
profession-woodcutting: '&eRequires Woodcutting Lvl {value}'
# Elemental Stat Formats
element: