!Added comments

This commit is contained in:
Indyuce 2020-12-24 17:43:45 +01:00
parent 22ea1c05a9
commit c884ba3d63
4 changed files with 31 additions and 26 deletions

View File

@ -23,11 +23,11 @@ public class ItemSet {
private final List<String> loreTag;
private final String name, id;
/*
* arbitrary constant that only determines the maximum amount of items in a
/**
* Arbitrary constant that only determines the maximum amount of items in a
* set e.g if set to 11 you can't create buffs that apply when a player
* wears at least 11 items of the same set. has to be higher than 5 for
* CUSTOM INVENTORY plugins
* wears at least 11 items of the same set. Has to be higher than 5 for
* CUSTOM INVENTORY plugins but it does not have to be tremendously high
*/
private static final int itemLimit = 10;
@ -61,14 +61,6 @@ public class ItemSet {
continue;
}
if (key.startsWith("arrow-effect-")) {
PotionEffectType potionEffectType = PotionEffectType.getByName(format.substring("arrow-effect-".length()));
Validate.notNull(potionEffectType, "Could not load potion effect type from '" + format + "'");
bonuses.addPotionEffect(new PotionEffect(potionEffectType, MMOUtils.getEffectDuration(potionEffectType),
config.getInt("bonuses." + j + "." + key) - 1, true, false));
continue;
}
// particle effect
if (key.startsWith("particle-")) {
bonuses.addParticle(new ParticleData(config.getConfigurationSection("bonuses." + j + "." + key)));
@ -109,17 +101,10 @@ public class ItemSet {
}
public static class SetBonuses {
private final Map<ItemStat, Double> stats;
private final Map<PotionEffectType, PotionEffect> permEffects;
private final Set<AbilityData> abilities;
private final Set<ParticleData> particles;
public SetBonuses() {
stats = new HashMap<>();
permEffects = new HashMap<>();
abilities = new HashSet<>();
particles = new HashSet<>();
}
private final Map<ItemStat, Double> stats = new HashMap<>();
private final Map<PotionEffectType, PotionEffect> permEffects = new HashMap<>();
private final Set<AbilityData> abilities = new HashSet<>();
private final Set<ParticleData> particles = new HashSet<>();
public void addStat(ItemStat stat, double value) {
stats.put(stat, value);

View File

@ -26,11 +26,18 @@ public class SoulboundInfo {
private final Location loc;
private final Player player;
/**
* Used to store which items must be given back to which player
*/
private static final Map<UUID, SoulboundInfo> info = new HashMap<>();
/**
* Used when a player dies and when some items must not be dropped and needs
* to be cached before the player respawns
* Instanced when a player dies if some souljbound items must be kept in the
* player's inventory and need to be cached before the player respawns.
*
* If the player leaves the server leaving one object of this type in server
* RAM, the cached items need to be dropped if the server closes before the
* player respawns again
*/
public SoulboundInfo(Player player) {
this.player = player;
@ -66,6 +73,10 @@ public class SoulboundInfo {
}
}
/**
* @return Soulbound info of players who have not clicked the respawn button
* and yet have items cached in server RAM
*/
public static Collection<SoulboundInfo> getAbandonnedInfo() {
return info.values();
}

View File

@ -53,7 +53,7 @@ public class MMOItemBuilder {
* Capacity is not final as it keeps lowering as modifiers are selected and
* applied
*/
double capacity = (tier != null && tier.hasCapacity() ? tier.getCapacity() : MMOItems.plugin.getLanguage().defaultItemCapacity).calculate(level);
double capacity = (tier != null && tier.hasCapacity() ? tier.getModifierCapacity() : MMOItems.plugin.getLanguage().defaultItemCapacity).calculate(level);
this.mmoitem = new MMOItem(template.getType(), template.getId());
// apply base item data

View File

@ -103,6 +103,15 @@ public class NumericStatFormula implements RandomStatData {
return maxSpread;
}
/**
* Applies the formula for a given input x.
*
* @param x Numeric input
* @return Let A = {base} + {scale} * x, then the returned value is a
* random value taken in respect to a gaussian distribution
* centered on A, with average spread of {spread}%, and with a
* maximum offset of {maxSpread}% (relative to average value)
*/
public double calculate(double x) {
return (base + scale * x) * (1 + Math.min(Math.max(random.nextGaussian() * spread, -maxSpread), maxSpread));
}