mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-03-01 15:51:03 +01:00
!Added comments
This commit is contained in:
parent
22ea1c05a9
commit
c884ba3d63
@ -23,11 +23,11 @@ public class ItemSet {
|
|||||||
private final List<String> loreTag;
|
private final List<String> loreTag;
|
||||||
private final String name, id;
|
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
|
* 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
|
* wears at least 11 items of the same set. Has to be higher than 5 for
|
||||||
* CUSTOM INVENTORY plugins
|
* CUSTOM INVENTORY plugins but it does not have to be tremendously high
|
||||||
*/
|
*/
|
||||||
private static final int itemLimit = 10;
|
private static final int itemLimit = 10;
|
||||||
|
|
||||||
@ -61,14 +61,6 @@ public class ItemSet {
|
|||||||
continue;
|
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
|
// particle effect
|
||||||
if (key.startsWith("particle-")) {
|
if (key.startsWith("particle-")) {
|
||||||
bonuses.addParticle(new ParticleData(config.getConfigurationSection("bonuses." + j + "." + key)));
|
bonuses.addParticle(new ParticleData(config.getConfigurationSection("bonuses." + j + "." + key)));
|
||||||
@ -109,17 +101,10 @@ public class ItemSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class SetBonuses {
|
public static class SetBonuses {
|
||||||
private final Map<ItemStat, Double> stats;
|
private final Map<ItemStat, Double> stats = new HashMap<>();
|
||||||
private final Map<PotionEffectType, PotionEffect> permEffects;
|
private final Map<PotionEffectType, PotionEffect> permEffects = new HashMap<>();
|
||||||
private final Set<AbilityData> abilities;
|
private final Set<AbilityData> abilities = new HashSet<>();
|
||||||
private final Set<ParticleData> particles;
|
private final Set<ParticleData> particles = new HashSet<>();
|
||||||
|
|
||||||
public SetBonuses() {
|
|
||||||
stats = new HashMap<>();
|
|
||||||
permEffects = new HashMap<>();
|
|
||||||
abilities = new HashSet<>();
|
|
||||||
particles = new HashSet<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addStat(ItemStat stat, double value) {
|
public void addStat(ItemStat stat, double value) {
|
||||||
stats.put(stat, value);
|
stats.put(stat, value);
|
||||||
|
@ -26,11 +26,18 @@ public class SoulboundInfo {
|
|||||||
private final Location loc;
|
private final Location loc;
|
||||||
private final Player player;
|
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<>();
|
private static final Map<UUID, SoulboundInfo> info = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used when a player dies and when some items must not be dropped and needs
|
* Instanced when a player dies if some souljbound items must be kept in the
|
||||||
* to be cached before the player respawns
|
* 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) {
|
public SoulboundInfo(Player player) {
|
||||||
this.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() {
|
public static Collection<SoulboundInfo> getAbandonnedInfo() {
|
||||||
return info.values();
|
return info.values();
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ public class MMOItemBuilder {
|
|||||||
* Capacity is not final as it keeps lowering as modifiers are selected and
|
* Capacity is not final as it keeps lowering as modifiers are selected and
|
||||||
* applied
|
* 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());
|
this.mmoitem = new MMOItem(template.getType(), template.getId());
|
||||||
|
|
||||||
// apply base item data
|
// apply base item data
|
||||||
|
@ -103,6 +103,15 @@ public class NumericStatFormula implements RandomStatData {
|
|||||||
return maxSpread;
|
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) {
|
public double calculate(double x) {
|
||||||
return (base + scale * x) * (1 + Math.min(Math.max(random.nextGaussian() * spread, -maxSpread), maxSpread));
|
return (base + scale * x) * (1 + Math.min(Math.max(random.nextGaussian() * spread, -maxSpread), maxSpread));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user