mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-02-27 15:31:22 +01:00
Musket stats now have placeholders
This commit is contained in:
parent
2bea05b08c
commit
1ce86e4861
@ -70,7 +70,7 @@ public class ItemStats {
|
||||
PARRY_RATING = new DoubleStat("PARRY_RATING", Material.BUCKET, "Parry Rating", new String[]{"The chance to parry an attack.", "Parrying negates the damage", "and knocks the attacker back."}, new String[]{"!miscellaneous", "!block", "all"}),
|
||||
PARRY_COOLDOWN_REDUCTION = new DoubleStat("PARRY_COOLDOWN_REDUCTION", Material.BUCKET, "Parry Cooldown Reduction", new String[]{"Reduces the parrying cooldown (%)."}, new String[]{"!miscellaneous", "!block", "all"}),
|
||||
COOLDOWN_REDUCTION = new DoubleStat("COOLDOWN_REDUCTION", Material.BOOK, "Cooldown Reduction", new String[]{"Reduces cooldowns of item and player skills (%)."}),
|
||||
RANGE = new DoubleStat("RANGE", Material.STICK, "Range", new String[]{"The range of your item attacks."}, new String[]{"staff", "whip", "wand", "musket"}),
|
||||
RANGE = new DoubleStat("RANGE", Material.STICK, "Range", new String[]{"The range of your item attacks."}, new String[]{"staff", "whip", "wand", "musket", "gem_stone"}),
|
||||
MANA_COST = new ManaCost(),
|
||||
STAMINA_COST = new DoubleStat("STAMINA_COST", VersionMaterial.LIGHT_GRAY_DYE.toMaterial(), "Stamina Cost", new String[]{"Stamina spent by your weapon to be used."}, new String[]{"piercing", "slashing", "blunt", "range"}),
|
||||
ARROW_VELOCITY = new DoubleStat("ARROW_VELOCITY", Material.ARROW, "Arrow Velocity", new String[]{"Determines how far your", "weapon can shoot.", "Default: 1.0"}, new String[]{"gem_stone", "bow", "crossbow"}),
|
||||
@ -101,9 +101,9 @@ public class ItemStats {
|
||||
UNBREAKABLE = new Unbreakable(),
|
||||
TIER = new ItemTierStat(),
|
||||
SET = new ItemSetStat(),
|
||||
ARMOR = new DoubleStat("ARMOR", VersionMaterial.GOLDEN_CHESTPLATE.toMaterial(), "Armor", new String[] { "The armor given to the holder." }),
|
||||
ARMOR_TOUGHNESS = new DoubleStat("ARMOR_TOUGHNESS", Material.DIAMOND_CHESTPLATE, "Armor Toughness", new String[] { "Armor toughness reduces damage taken." }),
|
||||
MAX_HEALTH = new DoubleStat("MAX_HEALTH", Material.GOLDEN_APPLE, "Max Health", new String[] { "The amount of health your", "item gives to the holder." }),
|
||||
ARMOR = new DoubleStat("ARMOR", VersionMaterial.GOLDEN_CHESTPLATE.toMaterial(), "Armor", new String[]{"The armor given to the holder."}),
|
||||
ARMOR_TOUGHNESS = new DoubleStat("ARMOR_TOUGHNESS", Material.DIAMOND_CHESTPLATE, "Armor Toughness", new String[]{"Armor toughness reduces damage taken."}),
|
||||
MAX_HEALTH = new DoubleStat("MAX_HEALTH", Material.GOLDEN_APPLE, "Max Health", new String[]{"The amount of health your", "item gives to the holder."}),
|
||||
UNSTACKABLE = new Unstackable(),
|
||||
MAX_MANA = new DoubleStat("MAX_MANA", VersionMaterial.LAPIS_LAZULI.toMaterial(), "Max Mana", new String[]{"Adds mana to your max mana bar."}),
|
||||
KNOCKBACK_RESISTANCE = new KnockbackResistance(),
|
||||
@ -168,16 +168,16 @@ public class ItemStats {
|
||||
REPAIR_TYPE = new RepairReference(),
|
||||
INEDIBLE = new BooleanStat("INEDIBLE", Material.POISONOUS_POTATO, "Inedible", new String[]{"Players won't be able to right-click this consumable.", "", "No effects of it will take place."}, new String[]{"consumable"}),
|
||||
DISABLE_RIGHT_CLICK_CONSUME = new DisableStat("RIGHT_CLICK_CONSUME", Material.BAKED_POTATO, "Infinite Consume", new String[]{"consumable"}, "Players will be able to right-click this consumable", "and benefit from its effects, but it won't be consumed."),
|
||||
KNOCKBACK = new DoubleStat("KNOCKBACK", VersionMaterial.IRON_HORSE_ARMOR.toMaterial(), "Knockback", new String[]{"Using this musket will knock", "the user back if positive."}, new String[]{"musket"}),
|
||||
RECOIL = new DoubleStat("RECOIL", VersionMaterial.IRON_HORSE_ARMOR.toMaterial(), "Recoil", new String[]{"Corresponds to the shooting innacuracy."}, new String[]{"musket"}),
|
||||
KNOCKBACK = new DoubleStat("KNOCKBACK", VersionMaterial.IRON_HORSE_ARMOR.toMaterial(), "Knockback", new String[]{"Using this musket will knock", "the user back if positive."}, new String[]{"musket", "gem_stone"}),
|
||||
RECOIL = new DoubleStat("RECOIL", VersionMaterial.IRON_HORSE_ARMOR.toMaterial(), "Recoil", new String[]{"Corresponds to the shooting innacuracy."}, new String[]{"musket", "gem_stone"}),
|
||||
HANDWORN = new BooleanStat("HANDWORN", Material.STRING, "Handworn", new String[]{"This item ignores two-handedness.", "", "Basically for a ring or a glove that you", " can wear and still have your hand free", " to carry a two-handed weapon."}, new String[]{"catalyst"}),
|
||||
AMPHIBIAN = new Amphibian(),
|
||||
|
||||
// Abilities & Upgrading
|
||||
ABILITIES = new Abilities(),
|
||||
UPGRADE = new UpgradeStat(),
|
||||
DOWNGRADE_ON_BREAK = new BooleanStat("BREAK_DOWNGRADE", Material.DAMAGED_ANVIL, "Downgrade when Broken", new String[]{"If this item's durability reaches 0,", "it will be fully repaired but also", "downgraded by one level.", "", "&cIt will only break if it cannot be", "&cdowngraded further", "", "Requires to define an &6Upgrade Template", "Required to define &6Custom Durability"}, new String[] { "piercing", "slashing", "blunt", "catalyst", "range", "tool", "armor", "consumable", "accessory" }),
|
||||
DOWNGRADE_ON_DEATH = new BooleanStat("DEATH_DOWNGRADE", Material.DAMAGED_ANVIL, "Downgrade on Death", new String[]{"If the wearer of this item dies, it may", "downgrade (based on &6Death Downgrade", "&6Chance &7stat)", "", "Required to define an &6Upgrade Template", "Requires keep-inventory gamerule. "}, new String[] { "piercing", "slashing", "blunt", "catalyst", "range", "tool", "armor", "consumable", "accessory" }),
|
||||
DOWNGRADE_ON_BREAK = new BooleanStat("BREAK_DOWNGRADE", Material.DAMAGED_ANVIL, "Downgrade when Broken", new String[]{"If this item's durability reaches 0,", "it will be fully repaired but also", "downgraded by one level.", "", "&cIt will only break if it cannot be", "&cdowngraded further", "", "Requires to define an &6Upgrade Template", "Required to define &6Custom Durability"}, new String[]{"piercing", "slashing", "blunt", "catalyst", "range", "tool", "armor", "consumable", "accessory"}),
|
||||
DOWNGRADE_ON_DEATH = new BooleanStat("DEATH_DOWNGRADE", Material.DAMAGED_ANVIL, "Downgrade on Death", new String[]{"If the wearer of this item dies, it may", "downgrade (based on &6Death Downgrade", "&6Chance &7stat)", "", "Required to define an &6Upgrade Template", "Requires keep-inventory gamerule. "}, new String[]{"piercing", "slashing", "blunt", "catalyst", "range", "tool", "armor", "consumable", "accessory"}),
|
||||
DOWNGRADE_ON_DEATH_CHANCE = new DoubleStat("DEATH_DOWNGRADE_CHANCE", Material.SKELETON_SKULL, "Death Downgrade Chance", new String[]{"Probability that an item with &cDowngrade ", "&con Death&7 will be downgraded when the", "player dies. ", "", "Exceeding 100% will for sure downgrade", "one item, and roll again to downgrade", "another (with the excess probability).", "&6The same item wont be downgraded twice."}, new String[]{"!miscellaneous", "!block", "all"}, false),
|
||||
|
||||
// Unique Item Stats
|
||||
@ -203,6 +203,7 @@ public class ItemStats {
|
||||
* @deprecated Item damage is now {@link ItemDamage} and
|
||||
* custom durability is now {@link CustomDurability}
|
||||
*/
|
||||
@Deprecated public static final ItemStat DURABILITY = ITEM_DAMAGE;
|
||||
@Deprecated
|
||||
public static final ItemStat DURABILITY = ITEM_DAMAGE;
|
||||
|
||||
}
|
||||
|
@ -176,7 +176,6 @@ public class MMOItems extends JavaPlugin {
|
||||
blockManager = new BlockManager();
|
||||
statManager.reload(false);
|
||||
|
||||
|
||||
PluginUtils.hookDependencyIfPresent("Vault", u -> vaultSupport = new VaultSupport());
|
||||
|
||||
getLogger().log(Level.INFO, "Loading crafting stations, please wait..");
|
||||
|
@ -12,6 +12,7 @@ import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@ -27,10 +28,10 @@ public class StatManager {
|
||||
* the first time to make their access easier. Check the classes
|
||||
* individually to understand better
|
||||
*/
|
||||
private final Set<DoubleStat> numeric = new HashSet<>();
|
||||
private final Set<ItemRestriction> itemRestriction = new HashSet<>();
|
||||
private final Set<ConsumableItemInteraction> consumableActions = new HashSet<>();
|
||||
private final Set<PlayerConsumable> playerConsumables = new HashSet<>();
|
||||
private final List<DoubleStat> numeric = new ArrayList<>();
|
||||
private final List<ItemRestriction> itemRestriction = new ArrayList<>();
|
||||
private final List<ConsumableItemInteraction> consumableActions = new ArrayList<>();
|
||||
private final List<PlayerConsumable> playerConsumables = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Load default stats using java reflection, get all public static final
|
||||
@ -51,13 +52,13 @@ public class StatManager {
|
||||
|
||||
/**
|
||||
* @see FictiveNumericStat
|
||||
* @deprecated
|
||||
* @deprecated Needs refactor
|
||||
*/
|
||||
@Deprecated
|
||||
public void reload(boolean cleanFirst) {
|
||||
|
||||
// Clean fictive numeric stats before
|
||||
if (cleanFirst)
|
||||
numeric.removeIf(stat -> stat instanceof FictiveNumericStat);
|
||||
if (cleanFirst) numeric.removeIf(stat -> stat instanceof FictiveNumericStat);
|
||||
|
||||
// Register elemental stats
|
||||
loadElements();
|
||||
@ -68,31 +69,31 @@ public class StatManager {
|
||||
|
||||
/**
|
||||
* Load custom stats
|
||||
*
|
||||
* @deprecated Needs refactor
|
||||
*/
|
||||
@Deprecated
|
||||
public void loadCustom() {
|
||||
ConfigManager.DefaultFile.CUSTOM_STATS.checkFile();
|
||||
ConfigFile config = new ConfigFile("custom-stats");
|
||||
ConfigurationSection section = config.getConfig().getConfigurationSection("custom-stats");
|
||||
Validate.notNull(section, "Custom stats section is null");
|
||||
section.getKeys(true)
|
||||
.stream()
|
||||
.filter(section::isConfigurationSection)
|
||||
.map(section::getConfigurationSection)
|
||||
.filter(Objects::nonNull)
|
||||
.forEach(this::registerCustomStat);
|
||||
section.getKeys(true).stream().filter(section::isConfigurationSection).map(section::getConfigurationSection).filter(Objects::nonNull).forEach(this::registerCustomStat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register all MythicLib elements as stats
|
||||
*
|
||||
* @deprecated Needs refactor
|
||||
*/
|
||||
@Deprecated
|
||||
public void loadElements() {
|
||||
for (ElementStatType type : ElementStatType.values()) {
|
||||
for (Element element : MythicLib.plugin.getElements().getAll()) {
|
||||
for (ElementStatType type : ElementStatType.values())
|
||||
for (Element element : MythicLib.plugin.getElements().getAll())
|
||||
numeric.add(new FictiveNumericStat(element, type));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Collection<ItemStat<?, ?>> getAll() {
|
||||
return stats.values();
|
||||
}
|
||||
@ -103,7 +104,8 @@ public class StatManager {
|
||||
* used when applying gem stones to quickly access all the stats
|
||||
* which needs to be applied
|
||||
*/
|
||||
public Set<DoubleStat> getNumericStats() {
|
||||
@NotNull
|
||||
public List<DoubleStat> getNumericStats() {
|
||||
return numeric;
|
||||
}
|
||||
|
||||
@ -111,7 +113,8 @@ public class StatManager {
|
||||
* @return Collection of all stats which constitute an item restriction:
|
||||
* required level, required class, soulbound..
|
||||
*/
|
||||
public Set<ItemRestriction> getItemRestrictionStats() {
|
||||
@NotNull
|
||||
public List<ItemRestriction> getItemRestrictionStats() {
|
||||
return itemRestriction;
|
||||
}
|
||||
|
||||
@ -119,7 +122,8 @@ public class StatManager {
|
||||
* @return Collection of all stats implementing a consumable action like
|
||||
* deconstructing, identifying...
|
||||
*/
|
||||
public Set<ConsumableItemInteraction> getConsumableActions() {
|
||||
@NotNull
|
||||
public List<ConsumableItemInteraction> getConsumableActions() {
|
||||
return consumableActions;
|
||||
}
|
||||
|
||||
@ -127,7 +131,8 @@ public class StatManager {
|
||||
* @return Collection of all stats implementing self consumable like
|
||||
* restore health, mana, hunger...
|
||||
*/
|
||||
public Set<PlayerConsumable> getPlayerConsumables() {
|
||||
@NotNull
|
||||
public List<PlayerConsumable> getPlayerConsumables() {
|
||||
return playerConsumables;
|
||||
}
|
||||
|
||||
@ -135,21 +140,17 @@ public class StatManager {
|
||||
return stats.containsKey(id);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ItemStat<?, ?> get(String id) {
|
||||
ItemStat<?, ?> stat = stats.getOrDefault(id, null);
|
||||
if (stat == null)
|
||||
stat = numeric.stream()
|
||||
.filter(doubleStat -> doubleStat.getId().equals(id))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (stat == null) {
|
||||
stat = numeric.stream().filter(doubleStat -> doubleStat.getId().equals(id)).findFirst().orElse(null);
|
||||
if (stat != null) System.out.println("Found numeric for " + stat);
|
||||
}
|
||||
return stat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a stat in MMOItems
|
||||
*
|
||||
* @param id Useless.
|
||||
* @param stat The stat instance
|
||||
* @deprecated Stat IDs are now stored in the stat instance directly.
|
||||
* Please use StatManager#register(ItemStat) instead
|
||||
*/
|
||||
@ -166,23 +167,16 @@ public class StatManager {
|
||||
*
|
||||
* @param stat The stat to register
|
||||
*/
|
||||
public void register(ItemStat<?, ?> stat) {
|
||||
if (!stat.isEnabled())
|
||||
return;
|
||||
public void register(@NotNull ItemStat<?, ?> stat) {
|
||||
if (!stat.isEnabled()) return;
|
||||
|
||||
stats.put(stat.getId(), stat);
|
||||
|
||||
if (stat instanceof DoubleStat && !(stat instanceof GemStoneStat) && stat.isCompatible(Type.GEM_STONE))
|
||||
numeric.add((DoubleStat) stat);
|
||||
|
||||
if (stat instanceof ItemRestriction)
|
||||
itemRestriction.add((ItemRestriction) stat);
|
||||
|
||||
if (stat instanceof ConsumableItemInteraction)
|
||||
consumableActions.add((ConsumableItemInteraction) stat);
|
||||
|
||||
if (stat instanceof PlayerConsumable)
|
||||
playerConsumables.add((PlayerConsumable) stat);
|
||||
if (stat instanceof ItemRestriction) itemRestriction.add((ItemRestriction) stat);
|
||||
if (stat instanceof ConsumableItemInteraction) consumableActions.add((ConsumableItemInteraction) stat);
|
||||
if (stat instanceof PlayerConsumable) playerConsumables.add((PlayerConsumable) stat);
|
||||
|
||||
/*
|
||||
* Cache stat for every type which may have this stat. Really important
|
||||
@ -192,11 +186,7 @@ public class StatManager {
|
||||
* take it into account
|
||||
*/
|
||||
if (MMOItems.plugin.getTypes() != null)
|
||||
MMOItems.plugin.getTypes()
|
||||
.getAll()
|
||||
.stream()
|
||||
.filter(stat::isCompatible)
|
||||
.forEach(type -> type.getAvailableStats().add(stat));
|
||||
MMOItems.plugin.getTypes().getAll().stream().filter(stat::isCompatible).forEach(type -> type.getAvailableStats().add(stat));
|
||||
}
|
||||
|
||||
private void registerCustomStat(@NotNull ConfigurationSection section) {
|
||||
@ -229,10 +219,8 @@ public class StatManager {
|
||||
|
||||
// Lore
|
||||
String[] lore = new String[0];
|
||||
if (section.isList("lore"))
|
||||
lore = section.getStringList("lore").toArray(new String[]{});
|
||||
else if (section.isString("lore"))
|
||||
lore = new String[]{section.getString("lore")};
|
||||
if (section.isList("lore")) lore = section.getStringList("lore").toArray(new String[]{});
|
||||
else if (section.isString("lore")) lore = new String[]{section.getString("lore")};
|
||||
|
||||
// Create a new stat instance
|
||||
try {
|
||||
|
@ -0,0 +1,23 @@
|
||||
package net.Indyuce.mmoitems.stat.type;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Not used yet. This should be a class which tells MMOItems to
|
||||
* send the numeric stat value other to MythicLib player stats.
|
||||
*/
|
||||
@Deprecated
|
||||
public class PlayerStat extends DoubleStat {
|
||||
public PlayerStat(String id, Material mat, String name, String[] lore) {
|
||||
this(id, mat, name, lore, new String[]{"!miscellaneous", "!block", "all"}, true);
|
||||
}
|
||||
|
||||
public PlayerStat(String id, Material mat, String name, String[] lore, String[] types, Material... materials) {
|
||||
this(id, mat, name, lore, types, true, materials);
|
||||
}
|
||||
|
||||
public PlayerStat(String id, Material mat, String name, String[] lore, String[] types, boolean moreIsBetter, Material... materials) {
|
||||
super(id, mat, name, lore, types, moreIsBetter, materials);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user