Skip to content
This repository was archived by the owner on Feb 17, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ private ReinforcementType parseReinforcementType(ConfigurationSection config) {
double decayMultiplier = config.getDouble("decay_multiplier", globalDecayMultiplier);
double multiplerOnDeletedGroup = config.getDouble("deleted_group_multipler", 4);
int legacyId = config.getInt("legacy_id", -1);
boolean scalesWithBlockHardness = config.getBoolean("scales_with_block_hardness", true);
List<String> allowedWorlds = ConfigHelper.getStringList(config, "allowed_worlds");
if (name == null) {
logger.warning("No name specified for reinforcement type at " + config.getCurrentPath());
Expand All @@ -232,7 +233,8 @@ private ReinforcementType parseReinforcementType(ConfigurationSection config) {
+ gracePeriod + ", id: " + id + ", allowedWorlds: " + StringUtils.join(allowedWorlds, ", "));
return new ReinforcementType(health, returnChance, item, maturationTime, acidTime, acidPriority, maturationScale, gracePeriod,
creationEffect, damageEffect, destructionEffect, reinforceables, nonReinforceables, id, name,
globalBlackList, decayTimer, decayMultiplier, multiplerOnDeletedGroup, legacyId, allowedWorlds);
globalBlackList, decayTimer, decayMultiplier, multiplerOnDeletedGroup, legacyId, allowedWorlds,
scalesWithBlockHardness);
}

private void parseReinforcementTypes(ConfigurationSection config) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ public static float getDamageApplied(Reinforcement reinforcement) {
float damageAmount = 1.0F;
if (!reinforcement.isMature()) {
double timeExisted = System.currentTimeMillis() - reinforcement.getCreationTime();
double adjustedMaturationTime =
reinforcement.getType().scalesWithBlockHardness() ?
Math.sqrt(reinforcement.getLocation().getBlock().getType().getHardness()) * reinforcement.getType().getMaturationTime() :
reinforcement.getType().getMaturationTime();
double progress = timeExisted / reinforcement.getType().getMaturationTime();
damageAmount /= progress;
damageAmount *= reinforcement.getType().getMaturationScale();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ public boolean isInsecure() {
* reinforcements creation
*/
public boolean isMature() {
return System.currentTimeMillis() - creationTime > type.getMaturationTime();
double adjustedMaturationTime =
type.scalesWithBlockHardness() ?
Math.sqrt(location.getBlock().getType().getHardness()) * type.getMaturationTime() :
type.getMaturationTime();
return System.currentTimeMillis() - creationTime > adjustedMaturationTime;
}

public void setGroup(Group group) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ public class ReinforcementType {
private double deletedGroupMulitplier;
private int legacyId;
private Set<String> allowedWorlds;
private boolean typeScalesWithBlockHardness;

public ReinforcementType(float health, double returnChance, ItemStack item, long maturationTime, long acidTime, int acidPriority,
double scale, long gracePeriod, ReinforcementEffect creationEffect, ReinforcementEffect damageEffect,
ReinforcementEffect destructionEffect, Collection<Material> allowsReinforceables,
Collection<Material> disallowedReinforceables, short id, String name, Collection<Material> globalBlackList,
long decayTimer, double decayMultiplier, double deletedGroupMulitplier, int legacyId, Collection allowedWorlds) {
long decayTimer, double decayMultiplier, double deletedGroupMulitplier, int legacyId, Collection allowedWorlds,
boolean scalesWithBlockHardness) {
this.health = health;
this.name = name;
this.returnChance = returnChance;
Expand All @@ -48,6 +50,7 @@ public ReinforcementType(float health, double returnChance, ItemStack item, long
this.destructionEffect = destructionEffect;
this.gracePeriod = gracePeriod;
this.deletedGroupMulitplier = deletedGroupMulitplier;
this.typeScalesWithBlockHardness = scalesWithBlockHardness;
if (!allowsReinforceables.isEmpty()) {
this.allowedReinforceables = new TreeSet<>(allowsReinforceables);
} else {
Expand Down Expand Up @@ -104,6 +107,13 @@ public long getAcidTime() {
return acidTime;
}

/**
* @return whether maturation time for this type scales with block hardness
*/
public boolean scalesWithBlockHardness() {
return typeScalesWithBlockHardness;
}

/**
* @return the time in milli seconds to "forgive" reinforcements and apply 100%
* return rate. Set to 0 to disable.
Expand Down